https://sourceware.org/bugzilla/show_bug.cgi?id=20090
Bug ID: 20090 Summary: [Fix] clang fail on LTO phase with BFD linker (+patch) Product: binutils Version: 2.27 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: igor.venevtsev at gmail dot com Target Milestone: --- Created attachment 9256 --> https://sourceware.org/bugzilla/attachment.cgi?id=9256&action=edit reproducer Reproducer is just trying to make an executable using one object and two archives with LTO info inside. First arch, live.a, contains live() function which is called from main(). The second one, dead.a, contains never called function dead(). During linking phase, clang comply on 'Unexpected resolution' and terminates with UNREACHABLE. bash-4.3$ make [...skip...] Unexpected resolution UNREACHABLE executed at /users/ivvenevt/llvm/llvm/tools/gold/gold-plugin.cpp:759! clang-3.9: error: unable to execute command: Aborted (core dumped) clang-3.9: error: linker command failed due to signal (use -v to see invocation) Makefile:26: recipe for target 'test' failed The reason is wrong resolution reported by ld.bfd for dead (never included to link) symbols. When LTO plugin asks for dead symbol resolution via get_symbols() callback, ld.bfd is trying to find BFD entry for this symbol. But there is no BFD entry for dead symbol despite the symbol itself is defined (sym.def != LDPK_UNDEF). As a result ld.bfd set resolution to LDPR_UNKNOWN and confuses the LLVMgold.so plugin. Opposite, GOLD linker reports LDPR_PREEMPTED_REG for dead symbols. (gold/plugin.cc:959) Please find reproducer and patch in attachments. To run reproducer you should specify locations for clang and bfd.ld via CLANG_BIN and BINUTILS_BIN vars. Thanks, Igor -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils