mirror of
https://github.com/mirror/tinycc.git
synced 2026-09-05 12:14:52 +08:00
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.
This commit is contained in:
@@ -3345,6 +3345,25 @@ void test_asm_dead_code(void)
|
||||
asm volatile ("movl $0,(%0)" : : "D" (&var) : "memory");
|
||||
var;
|
||||
}));
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -3431,6 +3450,7 @@ void asm_test(void)
|
||||
asm volatile ("mov $0x4243, %%esi" : "=r" (regvar));
|
||||
printf ("regvar=%x\n", regvar);
|
||||
test_high_clobbers();
|
||||
trace_console(8, 8);
|
||||
test_asm_dead_code();
|
||||
test_asm_call();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user