aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-08-26 18:11:19 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:11 +0100
commit5bd8aeb917ed326f50b1ed45669a1cf40aca75a3 (patch)
treeeeaf074e00e4944e42a9cc80e8fd5a875e821237 /tests
parentdd57a348664d0fac46a0f4c822f70c80bbf97774 (diff)
downloadtinycc-5bd8aeb917ed326f50b1ed45669a1cf40aca75a3.tar.gz
tinycc-5bd8aeb917ed326f50b1ed45669a1cf40aca75a3.tar.bz2
tccasm: Support refs to anon symbols from asm
This happens when e.g. string constants (or other static data) are passed as operands to inline asm as immediates. The produced symbol ref wouldn't be found. So tighten the connection between C and asm-local symbol table even more.
Diffstat (limited to 'tests')
-rw-r--r--tests/tcctest.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c
index f8e2040..b8e534f 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -2741,6 +2741,28 @@ void override_func2 (void)
printf ("asmc: override2\n");
}
+/* This checks a construct used by the linux kernel to encode
+ references to strings by PC relative references. */
+extern int bug_table[] __attribute__((section("__bug_table")));
+char * get_asm_string (void)
+{
+ extern int some_symbol;
+ asm volatile (".globl some_symbol\n"
+ "jmp .+6\n"
+ "1:\n"
+ "some_symbol: .long 0\n"
+ ".pushsection __bug_table, \"a\"\n"
+ ".globl bug_table\n"
+ "bug_table:\n"
+ /* The first entry (1b-2b) is unused in this test,
+ but we include it to check if cross-section
+ PC-relative references work. */
+ "2:\t.long 1b - 2b, %c0 - 2b\n"
+ ".popsection\n" : : "i" ("A string"));
+ char * str = ((char*)bug_table) + bug_table[1];
+ return str;
+}
+
unsigned int set;
void asm_test(void)
@@ -2812,6 +2834,7 @@ void asm_test(void)
if (!somebool)
printf("asmbool: failed\n");
#endif
+ printf("asmstr: %s\n", get_asm_string());
return;
label1:
goto label2;