https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108851
Bug ID: 108851 Summary: gcc -pie generates unwanted PE export table Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pali at kernel dot org Target Milestone: --- When gcc is invoked with -pie option then for PE executables it automatically generates export table, even when executable does not export anything. Test case: $ cat test-pie.c int func(void) { return 42; } int main() { return func(); } $ x86_64-w64-mingw32-gcc -pie test-pie.c -o test-pie.exe $ x86_64-w64-mingw32-objdump -p test-pie.exe | grep -A 20 'There is an export table' There is an export table in .edata at 0x140008000 The Export Tables (interpreted .edata section contents) Export Flags 0 Time/Date stamp 63f2a29f Major/Minor 0/0 Name 0000000000008028 test-pie.exe Ordinal Base 1 Number in: Export Address Table 00000000 [Name Pointer/Ordinal] Table 00000000 Table Addresses Export Address Table 0000000000008028 Name Pointer Table 0000000000008028 Ordinal Table 0000000000008028 Export Address Table -- Ordinal Base 1 [Ordinal/Name Pointer] Table Without gcc's -pie option, executable does not have export table. Note that similar issue was reported also to LD https://sourceware.org/bugzilla/show_bug.cgi?id=30004 and proposed LD patch does not change behavior in this issue.