diff options
| author | Edmund Grimley Evans <Edmund.Grimley.Evans@gmail.com> | 2015-02-21 21:29:03 +0000 |
|---|---|---|
| committer | Edmund Grimley Evans <Edmund.Grimley.Evans@gmail.com> | 2015-02-21 21:29:03 +0000 |
| commit | 738606dbd5608cb2ed6789beecea40712809c397 (patch) | |
| tree | 5905c3fa381607f962f2cc75d68c280ab5d03eba /tccelf.c | |
| parent | 86c850fc58a70ff4b77c37d91e33ce6c812b04c4 (diff) | |
| download | tinycc-738606dbd5608cb2ed6789beecea40712809c397.tar.gz tinycc-738606dbd5608cb2ed6789beecea40712809c397.tar.bz2 | |
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.
Diffstat (limited to 'tccelf.c')
| -rw-r--r-- | tccelf.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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, |
