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: grischka
Subject: Re: [Tinycc-devel] forward asm symbols vs static
Date: Sun, 19 Nov 2017 21:37:54 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Michael Matz wrote:
Gnah, what a rats hole :-/ I found another failure mode that occurs only when defaulting asm labels to VT_STATIC/STB_LOCAL. I don't yet want to revert as it fixes demonstratable bugs, but OTOH I lack time tonight to fix this third problem as well. If you want to release soon, I'd suggest to revert d0db2175 back to a8ece0f2 (i.e. to a state where the alloca86_64.S/p3 reoccurs, like it always had in the past). If you can wait some more days with the release I'm going to fix it properly (hopefully).

I already decided to delay for one more week ;)

(FWIW the problem occurs when building multiple files into one executable (it works when compiling the files individually and then linking the .o files together) where the files each contain multiple asm snippets containing forward references that eventually turn out to be global. local symbols aren't entered into the ELF hash tables and when they are globalized later are missing from them, ultimately leading to linker errors. At least I think that's the reason :) This is all made a bit messy by the fact that the asm symtable lives only during one asm snippet, which is itself messy to fix because it shares the namespace with the C labels.)

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).

Below is some test that I just have tried.

--- 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]