aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-02-21 21:29:03 +0000
committerEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-02-21 21:29:03 +0000
commit738606dbd5608cb2ed6789beecea40712809c397 (patch)
tree5905c3fa381607f962f2cc75d68c280ab5d03eba /tccelf.c
parent86c850fc58a70ff4b77c37d91e33ce6c812b04c4 (diff)
downloadtinycc-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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tccelf.c b/tccelf.c
index 02caa68..dc0a144 100644
--- a/tccelf.c
+++ b/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,