tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] exporting uninitialized global symbols does not work


From: grischka
Subject: Re: [Tinycc-devel] exporting uninitialized global symbols does not work on PE
Date: Mon, 02 Nov 2020 18:15:35 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Robert Hölzl wrote:
Hello All

When creating a windows DLL you had to export global symbols (either via
the keyword "dllexport" or via command line parameter "-rdynamic").
This works fine for functions and global variables that are preinitialized.

But uninizalized variables are not exported (i.e. "int a = 1;" works
while "int a;" does not work).

The reason is, that "pe_build_exports()" in tccpe.c contains the
following check to filter all symbols that shall be exported:

if ((sym->st_other & ST_PE_EXPORT)
    /* export only symbols from actually written sections */
    && pe->s1->sections[sym->st_shndx]->sh_addr) {


The second condition of this if statment is the reason for the bug, as
uninitialized variables do not
have a corresponding address in a PE-section (they are generated
dynamicially on startup).

I removed that check.  Probably it was there for a reason once but
I don't remember what it was.  At best it is not needed anymore.

--- grischka

Any hints how I could modify that code?
I am not a PE expert and thus I do not know how uninitialized symbols
are represented in PE.

Best Regards,
Robert



reply via email to

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