[lld] r354972 - [DebugInfo] add SectionedAddress to DebugInfo interfaces.
Alexey Lapshin via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 27 05:17:36 PST 2019
Author: avl
Date: Wed Feb 27 05:17:36 2019
New Revision: 354972
URL: http://llvm.org/viewvc/llvm-project?rev=354972&view=rev
Log:
[DebugInfo] add SectionedAddress to DebugInfo interfaces.
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703
"wrong line number info for obj file compiled with -ffunction-sections"
bug. The problem happened with only .o files. If object file contains
several .text sections then line number information showed incorrectly.
The reason for this is that DwarfLineTable could not detect section which
corresponds to specified address(because address is the local to the
section). And as the result it could not select proper sequence in the
line table. The fix is to pass SectionIndex with the address. So that it
would be possible to differentiate addresses from various sections. With
this fix llvm-objdump shows correct line numbers for disassembled code.
Differential review: https://reviews.llvm.org/D58194
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=354972&r1=354971&r2=354972&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Feb 27 05:17:36 2019
@@ -205,14 +205,25 @@ Optional<DILineInfo> ObjFile<ELFT>::getD
uint64_t Offset) {
llvm::call_once(InitDwarfLine, [this]() { initializeDwarf(); });
+ // Detect SectionIndex for specified section.
+ uint64_t SectionIndex = object::SectionedAddress::UndefSection;
+ ArrayRef<InputSectionBase *> Sections = S->File->getSections();
+ for (uint64_t CurIndex = 0; CurIndex < Sections.size(); ++CurIndex) {
+ if (S == Sections[CurIndex]) {
+ SectionIndex = CurIndex;
+ break;
+ }
+ }
+
// Use fake address calcuated by adding section file offset and offset in
// section. See comments for ObjectInfo class.
DILineInfo Info;
- for (const llvm::DWARFDebugLine::LineTable *LT : LineTables)
+ for (const llvm::DWARFDebugLine::LineTable *LT : LineTables) {
if (LT->getFileLineInfoForAddress(
- S->getOffsetInFile() + Offset, nullptr,
+ {S->getOffsetInFile() + Offset, SectionIndex}, nullptr,
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Info))
return Info;
+ }
return None;
}
More information about the llvm-commits
mailing list