tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] exporting uninitialized global symbols does not work on P


From: Robert Hölzl
Subject: [Tinycc-devel] exporting uninitialized global symbols does not work on PE
Date: Thu, 22 Oct 2020 10:15:30 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1

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

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]