https://sourceware.org/bugzilla/show_bug.cgi?id=33180
Bug ID: 33180 Summary: LD cannot include symbol _pei386_runtime_relocator from AR archive Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: pali at kernel dot org Target Milestone: --- This issue could be related to bug #30343 but now it is without LTO involved. For indirect usage of _pei386_runtime_relocator, LD cannot locate this symbol in AR archive, but it can load it from ordinary object file. Test reproducer: First create simple library lib.dll with just one symbol "var": $ cat lib.c int var = 47; $ i686-w64-mingw32-gcc -c lib.c -o lib.o $ i686-w64-mingw32-ld -shared -entry 0 -s lib.o -o lib.dll Then create pseudo-reloc.a archive with dummy _pei386_runtime_relocator() implementation and variable _pei386_runtime_relocator_ptr with pointer to that function: $ cat pseudo-reloc.c void _pei386_runtime_relocator(void) {} void (*_pei386_runtime_relocator_ptr)(void) = _pei386_runtime_relocator; $ i686-w64-mingw32-gcc -c pseudo-reloc.c -o pseudo-reloc.o $ rm -f pseudo-reloc.a; i686-w64-mingw32-ar rcs pseudo-reloc.a pseudo-reloc.o And now the test case. Declare "var" variable without dllimport attribute (to trigger usage of pseudo relocator) and specify tentative definition for _pei386_runtime_relocator_ptr, and call it if is non-NULL. If pseudo-reloc is linked then it provides non-tentative definition of _pei386_runtime_relocator_ptr which should be used in the final variable. $ cat test.c extern int var; void (*_pei386_runtime_relocator_ptr)(void); __attribute__((used)) int mainCRTStartup(void) { if (_pei386_runtime_relocator_ptr) _pei386_runtime_relocator_ptr(); return var; } Compiling this code and linking everything together cause GNU LD linker error: $ i686-w64-mingw32-gcc -c test.c -o test.o $ i686-w64-mingw32-ld test.o lib.dll pseudo-reloc.a -o test.exe i686-w64-mingw32-ld: test_exe_ertr000004.o:(.rdata+0x0): undefined reference to `_pei386_runtime_relocator' When pseudo-reloc.a is replaced by pseudo-reloc.o then there is no error and GNU LD can find the _pei386_runtime_relocator symbol. So it looks like that GNU LD is not able to locate the _pei386_runtime_relocator symbol in AR archive pseudo-reloc.a but it is able to locate it in object file pseudo-reloc.o. -- You are receiving this mail because: You are on the CC list for the bug.