Summary: | [i386] lld emits malformed DWARF info for crt1.o | ||
---|---|---|---|
Product: | Base System | Reporter: | Mark Johnston <markj> |
Component: | bin | Assignee: | Mark Johnston <markj> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | CC: | emaste |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | i386 | ||
OS: | Any | ||
Bug Depends on: | |||
Bug Blocks: | 225128 |
Description
Mark Johnston
2018-06-04 21:02:48 UTC
The problem occurs with lld from the llvm-devel port as well: $ ld --version LLD 7.0.0 (compatible with GNU linkers) $ The problem has to do with lld's implementation of partial linking (-r). crt1.o is created with "ld -r -o crt1.o crt1_s.o crt1_c.o". Both input object files contain debug info and relocations against that debug info. Some of the relocations are against section symbols (STT_SECTION), so they must be processed before identical sections are merged. However, lld doesn't do any of that: 542 // This section contains relocation information. 543 // If -r is given, we do not interpret or apply relocation 544 // but just copy relocation sections to output. 545 if (Config->Relocatable) 546 return make<InputSection>(*this, Sec, Name); As a result, one of the DIEs in the output object file contains a DW_AT_stmt_list with a bogus value. That attribute is supposed to be an offset into .debug_line, and isn't getting adjusted properly when the two input .debug_line sections are concatenated. We can potentially work around this by combining crt1_c.c and crt1_s.S into one file, but that would be rather unsatisfying. I suspect that the next step would be to post to the LLVM ML and try to get a sense of how difficult this would be to fix. Oops, I should have tagged r336664 with this PR as well; I believe this issue should now be fixed. https://svnweb.freebsd.org/changeset/base/336664 (In reply to Ed Maste from comment #4) Confirmed fixed with r336664. Presumably we should MFC before marking the issue resolved? (In reply to Mark Johnston from comment #5) Sounds good. A commit references this bug: Author: emaste Date: Mon Jul 30 00:08:36 UTC 2018 New revision: 336880 URL: https://svnweb.freebsd.org/changeset/base/336880 Log: MFC r336664: lld: fix addends with partial linking [ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output. LLVM PR: 37735 LLVM Differential Revision: https://reviews.llvm.org/D48929 PR: 225128, 228753 Obtained from: LLVM r336799 by Igor Kudrin Changes: _U stable/11/ stable/11/contrib/llvm/tools/lld/ELF/InputSection.cpp r336664 now MFC'd as r336880 |