tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Help with tcc_add_symbol // pe_find_import in 0.9.27


From: draco
Subject: Re: [Tinycc-devel] Help with tcc_add_symbol // pe_find_import in 0.9.27
Date: Wed, 22 Jun 2022 07:51:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

grishka, thank you so much for pointing me in the right direction.

I was able to solve the problem (more or less) with this hint, though this means to patch tclDecls.h and tclIntDecls.h, two headers I took in from the tcl Source, so a bit problematic to maintain.

Furthermore, the __attribute__((dllimport)) is not needed, when compiling against libtclstubsXX.a, and was not needed in 0.9.26, behavior seems a bit inconsistent to me. Anyway, it's working for the moment...

Is this changed in later dev-versions?

Michael


IIRC tcc from 0.9.27 on tries to help with a more explicit error message
made just for that case:

    tcc: error: undefined symbol 'xxxx', missing __declspec(dllimport)?

See also the libtcc_test.c example:

    /* this strinc is referenced by the generated code */
    const char hello[] = "Hello World!";

    char my_program[] =
    "..."
    "#ifdef _WIN32\n" /* dynamically linked data needs 'dllimport' */
    " __attribute__((dllimport))\n"
    "#endif\n"
    "extern const char hello[];\n"

    [...]
    tcc_add_symbol(s, "hello", hello);

FYI, the change was necessary with the introduction of 64-bit targets
to the effect that data objects that are resolved via tcc_add_symbol()
are now accessed by the same mechanism as those that come from dlls.

This mechanism needs special code to be generated already at compile
time which is what happens when tcc sees __declspec(dllimport) (and
does not otherwise).

-- grischka


reply via email to

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