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: grischka
Subject: Re: [Tinycc-devel] Help with tcc_add_symbol // pe_find_import in 0.9.27
Date: Thu, 23 Jun 2022 00:21:09 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 22.06.2022 07:51, draco wrote:
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...

I can't help you to get back the buggy implementation from 0.9.26, but
maybe you want to declare 'dllimport' symbols without actually having
to use dllimport?  Then you might want to try this:

    tcc_define_symbol(s, "tclStubsPtr", "(*_imp__tclStubsPtr)");

which would redirect any usage of tclStubsPtr in client code as well
as provide a legal declaration for it from (non-patched) tclDefs.h:

   extern TclStubs *tclStubsPtr;

(-> extern TclStubs *(*_imp__tclStubsPtr); )

See also tcc/win32/include/stdlib.h for example:

   #define _environ (*_imp___environ)
   extern char ***_imp___environ;

--- grischka

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



_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

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