Use RELA relocations properly for R_DATA_PTR on x86_64.
libtcc.c: Add greloca, a generalisation of greloc that takes an addend. tcc.h: Add greloca and put_elf_reloca. tccelf.c: Add put_elf_reloca, a generalisation of put_elf_reloc. tccgen.c: On x86_64, use greloca instead of greloc in init_putv.
This commit is contained in:
15
tccelf.c
15
tccelf.c
@ -269,8 +269,8 @@ ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size,
|
||||
}
|
||||
|
||||
/* put relocation */
|
||||
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset,
|
||||
int type, int symbol)
|
||||
ST_FUNC void put_elf_reloca(Section *symtab, Section *s, unsigned long offset,
|
||||
int type, int symbol, unsigned long addend)
|
||||
{
|
||||
char buf[256];
|
||||
Section *sr;
|
||||
@ -292,10 +292,19 @@ ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset,
|
||||
rel->r_offset = offset;
|
||||
rel->r_info = ELFW(R_INFO)(symbol, type);
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
rel->r_addend = 0;
|
||||
rel->r_addend = addend;
|
||||
#else
|
||||
if (addend)
|
||||
tcc_error("non-zero addend on REL architecture");
|
||||
#endif
|
||||
}
|
||||
|
||||
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset,
|
||||
int type, int symbol)
|
||||
{
|
||||
put_elf_reloca(symtab, s, offset, type, symbol, 0);
|
||||
}
|
||||
|
||||
/* put stab debug information */
|
||||
|
||||
ST_FUNC void put_stabs(const char *str, int type, int other, int desc,
|
||||
|
||||
Reference in New Issue
Block a user