tccasm: Lookup C symbols from ASM blocks

It's now possible to use symbols defined in C code to be used
from later inline asm blocks.  See testcase.
This commit is contained in:
Michael Matz
2016-08-07 05:37:43 +02:00
parent c4edfb4e08
commit 9ae10cad1f
2 changed files with 71 additions and 19 deletions

View File

@ -2647,6 +2647,24 @@ void other_constraints_test(void)
int var;
__asm__ volatile ("movq %P1,%0" : "=r" (ret) : "p" (&var));
printf ("oc1: %d\n", ret == (unsigned long)&var);
}
/* Test global asm blocks playing with aliases. */
void base_func(void)
{
printf ("asmc: base\n");
}
extern void override_func1 (void);
extern void override_func2 (void);
asm(".weak override_func1\n.set override_func1, base_func");
asm(".set override_func1, base_func");
asm(".set override_func2, base_func");
void override_func2 (void)
{
printf ("asmc: override2\n");
}
unsigned int set;
@ -2655,6 +2673,10 @@ void asm_test(void)
{
char buf[128];
unsigned int val;
struct struct123 s1;
struct struct1231 s2 = { (unsigned long)&s1 };
/* Hide the outer base_func, but check later that the inline
asm block gets the outer one. */
int base_func = 42;
void override_func3 (void);
@ -2692,6 +2714,12 @@ void asm_test(void)
label2:
__asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc");
printf("set=0x%x\n", set);
val = 0x01020304;
printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val));
override_func1();
override_func2();
/* The base_func ref from the following inline asm should find
the global one, not the local decl from this function. */
asm volatile(".weak override_func3\n.set override_func3, base_func");
override_func3();
return;