aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-09-29 16:57:30 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:12 +0100
commitb5669a952babf486f0f8beb1e0a52d9031b3ae84 (patch)
tree4416b8940c31525f7df4e866c1e8547d0db75713
parent975c74c1f51679cfe62d1fd455344f12399fb51c (diff)
downloadtinycc-b5669a952babf486f0f8beb1e0a52d9031b3ae84.tar.gz
tinycc-b5669a952babf486f0f8beb1e0a52d9031b3ae84.tar.bz2
x86-64: relocation addend is 64bit
Some routines were using the wrong type (int) in passing addends, truncating it. This matters when bit 31 isn't set and the high 32 bits are set: the truncation would make it unsigned where in reality it's signed (happen e.g. on the x86-64 with it's load address at top-2GB).
-rw-r--r--i386-gen.c4
-rw-r--r--tcc.h4
-rw-r--r--x86_64-gen.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/i386-gen.c b/i386-gen.c
index ae40ca7..cd4cebd 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -165,14 +165,14 @@ ST_FUNC int oad(int c, int s)
}
/* output constant with relocation if 'r & VT_SYM' is true */
-ST_FUNC void gen_addr32(int r, Sym *sym, int c)
+ST_FUNC void gen_addr32(int r, Sym *sym, long c)
{
if (r & VT_SYM)
greloc(cur_text_section, sym, ind, R_386_32);
gen_le32(c);
}
-ST_FUNC void gen_addrpc32(int r, Sym *sym, int c)
+ST_FUNC void gen_addrpc32(int r, Sym *sym, long c)
{
if (r & VT_SYM)
greloc(cur_text_section, sym, ind, R_386_PC32);
diff --git a/tcc.h b/tcc.h
index a9641f6..a2e3d0d 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1478,8 +1478,8 @@ ST_FUNC void g(int c);
ST_FUNC int oad(int c, int s);
ST_FUNC void gen_le16(int c);
ST_FUNC void gen_le32(int c);
-ST_FUNC void gen_addr32(int r, Sym *sym, int c);
-ST_FUNC void gen_addrpc32(int r, Sym *sym, int c);
+ST_FUNC void gen_addr32(int r, Sym *sym, long c);
+ST_FUNC void gen_addrpc32(int r, Sym *sym, long c);
#endif
#ifdef CONFIG_TCC_BCHECK
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 6102be7..f5a2cdd 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -239,7 +239,7 @@ ST_FUNC int oad(int c, int s)
return s;
}
-ST_FUNC void gen_addr32(int r, Sym *sym, int c)
+ST_FUNC void gen_addr32(int r, Sym *sym, long c)
{
if (r & VT_SYM)
greloca(cur_text_section, sym, ind, R_X86_64_32S, c), c=0;
@@ -255,7 +255,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)
+ST_FUNC void gen_addrpc32(int r, Sym *sym, long c)
{
if (r & VT_SYM)
greloca(cur_text_section, sym, ind, R_X86_64_PC32, c-4), c=4;