mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-28 04:00:06 +08:00
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.
This commit is contained in:
parent
c4d0498b3a
commit
e264243adc
4
elf.h
4
elf.h
@ -2895,6 +2895,10 @@ typedef Elf32_Addr Elf32_Conflict;
|
||||
#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
|
||||
#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
|
||||
#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
|
||||
#define R_X86_64_GOTPCRELX 41 /* like GOTPCREL, but optionally with
|
||||
linker optimizations */
|
||||
#define R_X86_64_REX_GOTPCRELX 42 /* like GOTPCRELX, but a REX prefix
|
||||
is present */
|
||||
|
||||
#define R_X86_64_NUM 39
|
||||
|
||||
|
16
tccelf.c
16
tccelf.c
@ -941,8 +941,8 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
|
||||
write64le(ptr, val - rel->r_addend);
|
||||
break;
|
||||
case R_X86_64_GOTPCREL:
|
||||
case 41 /* R_X86_64_GOTPCRELX */:
|
||||
case 42 /* R_X86_64_REX_GOTPCRELX */:
|
||||
case R_X86_64_GOTPCRELX:
|
||||
case R_X86_64_REX_GOTPCRELX:
|
||||
write32le(ptr, read32le(ptr) +
|
||||
(s1->got->sh_addr - addr +
|
||||
s1->sym_attrs[sym_index].got_offset - 4));
|
||||
@ -1424,8 +1424,8 @@ ST_FUNC void build_got_entries(TCCState *s1)
|
||||
case R_X86_64_GOT32:
|
||||
case R_X86_64_GOTTPOFF:
|
||||
case R_X86_64_GOTPCREL:
|
||||
case 41 /* R_X86_64_GOTPCRELX */:
|
||||
case 42 /* R_X86_64_REX_GOTPCRELX */:
|
||||
case R_X86_64_GOTPCRELX:
|
||||
case R_X86_64_REX_GOTPCRELX:
|
||||
case R_X86_64_PLT32:
|
||||
sym_index = ELFW(R_SYM)(rel->r_info);
|
||||
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
||||
@ -1441,7 +1441,9 @@ ST_FUNC void build_got_entries(TCCState *s1)
|
||||
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
||||
}
|
||||
if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
|
||||
type == R_X86_64_PLT32 || type == 41 || type == 42) {
|
||||
type == R_X86_64_GOTPCRELX ||
|
||||
type == R_X86_64_REX_GOTPCRELX ||
|
||||
type == R_X86_64_PLT32) {
|
||||
unsigned long ofs;
|
||||
/* look at the symbol got offset. If none, then add one */
|
||||
if (type == R_X86_64_PLT32)
|
||||
@ -1773,8 +1775,8 @@ ST_FUNC void fill_got(TCCState *s1)
|
||||
switch (ELFW(R_TYPE) (rel->r_info)) {
|
||||
case R_X86_64_GOT32:
|
||||
case R_X86_64_GOTPCREL:
|
||||
case 41 /* R_X86_64_GOTPCRELX */:
|
||||
case 42 /* R_X86_64_REX_GOTPCRELX */:
|
||||
case R_X86_64_GOTPCRELX:
|
||||
case R_X86_64_REX_GOTPCRELX:
|
||||
case R_X86_64_PLT32:
|
||||
fill_got_entry(s1, rel);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user