tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] forward asm symbols vs static


From: Michael Matz
Subject: Re: [Tinycc-devel] forward asm symbols vs static
Date: Mon, 20 Nov 2017 19:32:31 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hi,

On Sun, 19 Nov 2017, grischka wrote:

> I admit that tccasm.c is one of the white areas on my tcc map, but 
> naively I'd think that it probably should more closely emulate the gcc 
> situation where inline asm ends up just as embedded snippets in its C -> 
> asm output.  Which could mean for example that "free_asm_labels" should 
> be called only once at the end of each "translation unit" (file).

Yes, that would be the ultimate goal.  As said, this would elevate the 
problem of sharing C-label and asm-label namespace, which already is a 
problem right now, even more.  So that needs solving, preferably without 
needing too much additional memory, then the move to a single end-of-file 
free_asm_labels, and then all is sunny :)

> Below is some test that I just have tried.

Yep, a conscise example of all asm- symbol table problems we have right 
now :)

Ciao,
Michael.

> 
> --- grischka
> 
> $ gcc -c t1.c t2.c && gcc t1.o t2.o -o t.exe && t.exe
> x1
> x2
> x3
> 
> $ tcc -c t1.c t2.c && tcc t1.o t2.o -o t.exe && t.exe
> tcc: error: undefined symbol 'x1'
> tcc: error: undefined symbol 'x2'
> 
> $ tcc t1.c t2.c -o t.exe && t.exe
> tcc: error: undefined symbol 'x1'
> tcc: error: undefined symbol 'x2'
> 
> /***********************/
> /* T1.C */
> 
> #include <stdio.h>
> 
> #if defined _WIN32 && !defined __TINYC__
> # define U "_"
> #else
> # define U
> #endif
> 
> const char str[] = "x1\n";
> asm(U"x1: push $"U"str; call "U"printf; pop %ecx; ret");
> 
> int main(int argc, char *argv[])
> {
>     asm("call "U"x1");
>     asm("call "U"x2");
>     asm("call "U"x3");
>     return 0;
> }
> 
> static
> int x2(void)
> {
>     printf("x2\n");
>     return 2;
> }
> 
> extern int x3(void);
> 
> 
> /***********************/
> /* T2.C */
> 
> #include <stdio.h>
> 
> int x3(void)
> {
>     printf("x3\n");
>     return 3;
> }
> 
> > 
> > 
> > Ciao,
> > Michael.
> > 
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]