History

x86-64: Define symbol constant for new relocs

Whoops, we have our own <elf.h> copy, so I can just as well add the symbol defines for the relocs instead of hard-coding numbers in tccelf.c.

Michael Matz committed 10 years ago

Commit e2642431 parent c4d04982 files · +13 −7Browse files

Unified · Split

2 files
  1. elf.h +4 −0
  2. tccelf.c +9 −7
elf.h+4−0
@@ -2895,6 +2895,10 @@ typedef Elf32_Addr Elf32_Conflict; · 2894 unmodified lines
28952895 #define R_X86_64_TLSDESC 36 /* TLS descriptor. */
28962896 #define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
28972897 #define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
2898+#define R_X86_64_GOTPCRELX 41 /* like GOTPCREL, but optionally with
2899+ linker optimizations */
2900+#define R_X86_64_REX_GOTPCRELX 42 /* like GOTPCRELX, but a REX prefix
2901+ is present */
28982902
28992903 #define R_X86_64_NUM 39
29002904
tccelf.c+9−7
@@ -941,8 +941,8 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 940 unmodified lines
941941 write64le(ptr, val - rel->r_addend);
942942 break;
943943 case R_X86_64_GOTPCREL:
944− case 41 /* R_X86_64_GOTPCRELX */:
945− case 42 /* R_X86_64_REX_GOTPCRELX */:
944+ case R_X86_64_GOTPCRELX:
945+ case R_X86_64_REX_GOTPCRELX:
946946 write32le(ptr, read32le(ptr) +
947947 (s1->got->sh_addr - addr +
948948 s1->sym_attrs[sym_index].got_offset - 4));
@@ -1424,8 +1424,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 475 unmodified lines
14241424 case R_X86_64_GOT32:
14251425 case R_X86_64_GOTTPOFF:
14261426 case R_X86_64_GOTPCREL:
1427− case 41 /* R_X86_64_GOTPCRELX */:
1428− case 42 /* R_X86_64_REX_GOTPCRELX */:
1427+ case R_X86_64_GOTPCRELX:
1428+ case R_X86_64_REX_GOTPCRELX:
14291429 case R_X86_64_PLT32:
14301430 sym_index = ELFW(R_SYM)(rel->r_info);
14311431 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
@@ -1441,7 +1441,9 @@ ST_FUNC void build_got_entries(TCCState *s1) · 9 unmodified lines
14411441 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
14421442 }
14431443 if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
1444− type == R_X86_64_PLT32 || type == 41 || type == 42) {
1444+ type == R_X86_64_GOTPCRELX ||
1445+ type == R_X86_64_REX_GOTPCRELX ||
1446+ type == R_X86_64_PLT32) {
14451447 unsigned long ofs;
14461448 /* look at the symbol got offset. If none, then add one */
14471449 if (type == R_X86_64_PLT32)
@@ -1773,8 +1775,8 @@ ST_FUNC void fill_got(TCCState *s1) · 325 unmodified lines
17731775 switch (ELFW(R_TYPE) (rel->r_info)) {
17741776 case R_X86_64_GOT32:
17751777 case R_X86_64_GOTPCREL:
1776− case 41 /* R_X86_64_GOTPCRELX */:
1777− case 42 /* R_X86_64_REX_GOTPCRELX */:
1778+ case R_X86_64_GOTPCRELX:
1779+ case R_X86_64_REX_GOTPCRELX:
17781780 case R_X86_64_PLT32:
17791781 fill_got_entry(s1, rel);
17801782 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t