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
2895#define R_X86_64_TLSDESC 36 /* TLS descriptor. */2895#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
2896#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */2896#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
2897#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */2897#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 */
2898 2902
2899#define R_X86_64_NUM 392903#define R_X86_64_NUM 39
2900 2904
tccelf.c+9−7
@@ -941,8 +941,8 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 940 unmodified lines
941 write64le(ptr, val - rel->r_addend);941 write64le(ptr, val - rel->r_addend);
942 break;942 break;
943 case R_X86_64_GOTPCREL:943 case R_X86_64_GOTPCREL:
944 case 41 /* R_X86_64_GOTPCRELX */:944 case R_X86_64_GOTPCRELX:
945 case 42 /* R_X86_64_REX_GOTPCRELX */:945 case R_X86_64_REX_GOTPCRELX:
946 write32le(ptr, read32le(ptr) +946 write32le(ptr, read32le(ptr) +
947 (s1->got->sh_addr - addr +947 (s1->got->sh_addr - addr +
948 s1->sym_attrs[sym_index].got_offset - 4));948 s1->sym_attrs[sym_index].got_offset - 4));
@@ -1424,8 +1424,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 475 unmodified lines
1424 case R_X86_64_GOT32:1424 case R_X86_64_GOT32:
1425 case R_X86_64_GOTTPOFF:1425 case R_X86_64_GOTTPOFF:
1426 case R_X86_64_GOTPCREL:1426 case R_X86_64_GOTPCREL:
1427 case 41 /* R_X86_64_GOTPCRELX */:1427 case R_X86_64_GOTPCRELX:
1428 case 42 /* R_X86_64_REX_GOTPCRELX */:1428 case R_X86_64_REX_GOTPCRELX:
1429 case R_X86_64_PLT32:1429 case R_X86_64_PLT32:
1430 sym_index = ELFW(R_SYM)(rel->r_info);1430 sym_index = ELFW(R_SYM)(rel->r_info);
1431 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];1431 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
@@ -1441,7 +1441,9 @@ ST_FUNC void build_got_entries(TCCState *s1) · 9 unmodified lines
1441 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];1441 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
1442 }1442 }
1443 if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||1443 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) {
1445 unsigned long ofs;1447 unsigned long ofs;
1446 /* look at the symbol got offset. If none, then add one */1448 /* look at the symbol got offset. If none, then add one */
1447 if (type == R_X86_64_PLT32)1449 if (type == R_X86_64_PLT32)
@@ -1773,8 +1775,8 @@ ST_FUNC void fill_got(TCCState *s1) · 325 unmodified lines
1773 switch (ELFW(R_TYPE) (rel->r_info)) {1775 switch (ELFW(R_TYPE) (rel->r_info)) {
1774 case R_X86_64_GOT32:1776 case R_X86_64_GOT32:
1775 case R_X86_64_GOTPCREL:1777 case R_X86_64_GOTPCREL:
1776 case 41 /* R_X86_64_GOTPCRELX */:1778 case R_X86_64_GOTPCRELX:
1777 case 42 /* R_X86_64_REX_GOTPCRELX */:1779 case R_X86_64_REX_GOTPCRELX:
1778 case R_X86_64_PLT32:1780 case R_X86_64_PLT32:
1779 fill_got_entry(s1, rel);1781 fill_got_entry(s1, rel);
1780 break;1782 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