https://sourceware.org/bugzilla/show_bug.cgi?id=26588
Bug ID: 26588 Summary: enable-reloc-section on .exe with no exported symbols causes segfault if requested to create implib Product: binutils Version: 2.36 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: sourceware-bugzilla at jdrake dot com Target Milestone: --- Created attachment 12824 --> https://sourceware.org/bugzilla/attachment.cgi?id=12824&action=edit proposed patch PR #17321 added --enable-reloc-section, and PR #19011 made it default. However, some (misguided) tools try to create import libraries for executables, even if they don't export any symbols. This didn't cause a failure previously, but now segfaults if --enable-reloc-section is enabled. 0:000> kb # RetAddr : Args to Child : Call Site 00 00007ff6`f8aa4907 : 00000000`00000000 00000001`40023760 0000003c`5dbff9ec 00000000`00000044 : msvcrt!strlen+0x31 01 00007ff6`f898f53b : 00000000`00000000 00007ff6`f897618a 0000003c`5dbff9f0 00007ff6`f89680f0 : ld!xstrdup+0x17 [..\..\binutils-2.35\libiberty\xstrdup.c @ 33] 02 00007ff6`f8980a08 : 000001a9`af6758a0 000001a9`ad6d88b0 00007ff6`f8c618c0 00007ff6`f89680f0 : ld!pep_dll_generate_implib+0x53 [..\..\binutils-2.35\ld\pe-dll.c @ 2822] 03 00007ff6`f8975c27 : 0000003c`5dbffabc 0000000a`af68bd50 00000000`00000025 00000001`00000044 : ld!gld_i386pep_finish+0xb1 [ei386pep.c @ 1823] 04 00007ff6`f896ab7d : 00000000`00000004 00007ff6`00000001 00000000`00000000 00007ff6`f8976050 : ld!ldemul_finish+0x15 [..\..\binutils-2.35\ld\ldemul.c @ 102] 05 00007ff6`f896f22e : 00007ff6`f8b14608 00007ff6`f8b067c0 000001a9`00000001 00007ffc`50000061 : ld!lang_process+0x6c6 [..\..\binutils-2.35\ld\ldlang.c @ 8126] 06 00007ff6`f89513c1 : 00000000`00000025 000001a9`ad6d1b40 00007ff6`f8c67398 00000000`00000000 : ld!main+0x795 [..\..\binutils-2.35\ld\ldmain.c @ 498] 07 00007ff6`f89514f6 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ld!__tmainCRTStartup+0x231 [D:\mingwbuild\mingw-w64-crt-git\src\mingw-w64\mingw-w64-crt\crt\crtexe.c @ 337] 08 00007ffc`a86b6fd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ld!mainCRTStartup+0x16 [D:\mingwbuild\mingw-w64-crt-git\src\mingw-w64\mingw-w64-crt\crt\crtexe.c @ 221] 09 00007ffc`a9b1cec1 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x14 0a 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21 This is dll_filename = (def->name) ? def->name : dll_name; dll_symname = xstrdup (dll_filename); the global dll_name is filled in if def->name is not set in generate_edata, however if (pe_def_file->num_exports == 0 && !bfd_link_pic (info)) { if (pe_dll_enable_reloc_section) { build_filler_bfd (0); pe_output_file_set_long_section_names (filler_bfd); } return; } generate_edata (abfd, info); build_filler_bfd (1); pe_output_file_set_long_section_names (filler_bfd); I'm not sure whether it would be better to call generate_edata in the no exports but enable reloc section case, or my proposed patch (attached) -- You are receiving this mail because: You are on the CC list for the bug.