aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-07-10 22:29:28 +0200
committerMichael Matz <matz@suse.de>2017-07-10 22:29:28 +0200
commit2acb04f7f2077a4cff103421d79ceee48441918a (patch)
treeb7ac49fd8970c672c542874131c47afa7b92245c /tests
parent9bea88d61611dc12eeb211e342461f9157177464 (diff)
downloadtinycc-2acb04f7f2077a4cff103421d79ceee48441918a.tar.gz
tinycc-2acb04f7f2077a4cff103421d79ceee48441918a.tar.bz2
tccasm: Fix local statics referenced from asms
The assembler uses the ->sym_scope member to walk up the symbols until finding a non-automatic symbol. Since reordering the members of Sym the sym_scope member contains a scope even for local statics. Formerly the use of asm_label for statics was implicitely clearing sym_scope, now we have to do that explicitely. Add a testcase for that, and one I encountered when moving the clearing of sym_scope too deep into the call chain (into put_extern_sym).
Diffstat (limited to 'tests')
-rw-r--r--tests/tcctest.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c
index f657c14..2add498 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -3205,6 +3205,34 @@ char * get_asm_string (void)
char * str = ((char*)bug_table) + bug_table[1];
return str;
}
+
+/* This checks another constructs with local labels. */
+extern unsigned char alld_stuff[];
+asm(".data\n"
+ ".byte 41\n"
+ "alld_stuff:\n"
+ "661:\n"
+ ".byte 42\n"
+ "662:\n"
+ ".pushsection .data.ignore\n"
+ ".long 661b - .\n" /* This reference to 661 generates an external sym
+ which shouldn't somehow overwrite the offset that's
+ already determined for it. */
+ ".popsection\n"
+ ".byte 662b - 661b\n" /* So that this value is undeniably 1. */);
+
+void asm_local_label_diff (void)
+{
+ printf ("asm_local_label_diff: %d %d\n", alld_stuff[0], alld_stuff[1]);
+}
+
+/* This checks that static local variables are available from assembler. */
+void asm_local_statics (void)
+{
+ static int localint = 41;
+ asm("incl %0" : "+m" (localint));
+ printf ("asm_local_statics: %d\n", localint);
+}
#endif
unsigned int set;
@@ -3378,6 +3406,8 @@ void asm_test(void)
asm volatile(".weak override_func3\n.set override_func3, base_func");
override_func3();
printf("asmstr: %s\n", get_asm_string());
+ asm_local_label_diff();
+ asm_local_statics();
#endif
/* Check that we can also load structs of appropriate layout
into registers. */