aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Pavlas <zden3k@gmail.com>2017-09-11 05:56:47 -0700
committerZdenek Pavlas <zden3k@gmail.com>2017-09-11 06:36:16 -0700
commit870271ea071971002fa556e09e1873db316fa1a9 (patch)
tree30933c4ba086c73f8c409bab727d8f2e03ff8d54
parent078d8c2c5a008f710ba5349fdc2a21a12a128f58 (diff)
downloadtinycc-870271ea071971002fa556e09e1873db316fa1a9.tar.gz
tinycc-870271ea071971002fa556e09e1873db316fa1a9.tar.bz2
gen_addrpc32: absolute ptr needs *ABS* relocation
Dereferencing of absolute pointers is broken on x86_64, eg: *(int*)NULL does not segfault but returns -4 instead *(char*)(-10L << 20) does not return 0x55 (vsyscall page, push rbp)
-rw-r--r--x86_64-gen.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index a71e209..72842d6 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -257,8 +257,7 @@ ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c)
/* output constant with relocation if 'r & VT_SYM' is true */
ST_FUNC void gen_addrpc32(int r, Sym *sym, int c)
{
- if (r & VT_SYM)
- greloca(cur_text_section, sym, ind, R_X86_64_PC32, c-4), c=4;
+ greloca(cur_text_section, sym, ind, R_X86_64_PC32, 0);
gen_le32(c-4);
}