aboutsummaryrefslogtreecommitdiff
path: root/tests/tcctest.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-10-09 00:44:22 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:49:55 +0100
commit235711f3d3a5a41a4bb51a22dca6700aa77d34c1 (patch)
tree19a5969c24864534990e90f6f37b58addedb7933 /tests/tcctest.c
parenta2a596e76724a7915361b4d0f1b5553929d26a31 (diff)
downloadtinycc-235711f3d3a5a41a4bb51a22dca6700aa77d34c1.tar.gz
tinycc-235711f3d3a5a41a4bb51a22dca6700aa77d34c1.tar.bz2
64bit: Fix addends > 32 bits
If a symbolic reference is offsetted by a constant > 32bit the backends can't deal with that, so don't construct such values.
Diffstat (limited to 'tests/tcctest.c')
-rw-r--r--tests/tcctest.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 5124a4f..bdbcb60 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -2429,6 +2429,19 @@ void getmyaddress(void)
{
printf("in getmyaddress\n");
}
+
+#ifdef __LP64__
+long __pa_symbol(void)
+{
+ /* This 64bit constant was handled incorrectly, it was used as addend
+ (which can hold 64bit just fine) in connection with a symbol,
+ and TCC generates wrong code for that (displacements are 32bit only).
+ This effectively is "+ 0x80000000", and if addresses of globals
+ are below 2GB the result should be a number without high 32 bits set. */
+ return ((long)(((unsigned long)(&rel1))) - (0xffffffff80000000UL));
+}
+#endif
+
unsigned long theaddress = (unsigned long)getmyaddress;
void relocation_test(void)
{
@@ -2436,6 +2449,9 @@ void relocation_test(void)
printf("*rel1=%d\n", *rel1);
printf("*rel2=%d\n", *rel2);
fptr();
+#ifdef __LP64__
+ printf("pa_symbol=0x%lx\n", __pa_symbol() >> 63);
+#endif
}
void old_style_f(a,b,c)