diff options
| author | Michael Matz <matz@suse.de> | 2017-11-16 13:29:59 +0100 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2017-11-16 13:29:59 +0100 |
| commit | a8ece0f2ce3d2c2471fc8ddb7109938ecec333f7 (patch) | |
| tree | 79c883f475dcdefafba24e99f1cd143a5a5dadaa /tests | |
| parent | 348dd9f4a68a5a6217142c64070765733af3a8c8 (diff) | |
| download | tinycc-a8ece0f2ce3d2c2471fc8ddb7109938ecec333f7.tar.gz tinycc-a8ece0f2ce3d2c2471fc8ddb7109938ecec333f7.tar.bz2 | |
Don't make forard asm symbols static by default
fixes the problem in the testcase. A symbolic reference
from asm, which remains undefined at the end of processing is
always a global reference, not a static (STB_LOCAL) one.
This also affected the linux kernel.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tcctest.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c index 099fc35..d6fb7e2 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -3345,6 +3345,25 @@ void test_asm_dead_code(void) })); } +void test_asm_call(void) +{ +#if defined __x86_64__ && !defined _WIN64 + static char str[] = "PATH"; + char *s; + /* This tests if a reference to an undefined symbol from an asm + block, which isn't otherwise referenced in this file, is correctly + regarded as global symbol, so that it's resolved by other object files + or libraries. We chose getenv here, which isn't used anywhere else + in this file. (If we used e.g. printf, which is used we already + would have a global symbol entry, not triggering the bug which is + tested here). */ + /* two pushes so stack remains aligned */ + asm volatile ("push %%rdi; push %%rdi; mov %0, %%rdi; call getenv; pop %%rdi; pop %%rdi" + : "=a" (s) : "r" (str)); + printf("asmd: %s\n", s); +#endif +} + void asm_test(void) { char buf[128]; @@ -3431,6 +3450,7 @@ void asm_test(void) test_high_clobbers(); trace_console(8, 8); test_asm_dead_code(); + test_asm_call(); return; label1: goto label2; |
