diff options
| author | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-02-27 13:17:36 +0000 |
|---|---|---|
| committer | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-02-27 13:17:36 +0000 |
| commit | 77fc1f6049a7414ec193c9ff8226eeb5662a5878 (patch) | |
| tree | b2bffed96e676b25942dbe39194e0f08a153f638 /llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp | |
| parent | ef920358277603c69f4f548d2e5c40842972dd71 (diff) | |
| download | bcm5719-llvm-77fc1f6049a7414ec193c9ff8226eeb5662a5878.tar.gz bcm5719-llvm-77fc1f6049a7414ec193c9ff8226eeb5662a5878.zip | |
[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
llvm-svn: 354972
Diffstat (limited to 'llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp')
| -rw-r--r-- | llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp index a3750a2735d..ff2ce46a01d 100644 --- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp +++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp @@ -254,7 +254,8 @@ FileAnalysis::getDirectControlFlowXRefs(const Instr &InstrMeta) const { return CFCrossReferences; } -const std::set<uint64_t> &FileAnalysis::getIndirectInstructions() const { +const std::set<object::SectionedAddress> & +FileAnalysis::getIndirectInstructions() const { return IndirectInstructions; } @@ -268,8 +269,10 @@ const MCInstrAnalysis *FileAnalysis::getMCInstrAnalysis() const { return MIA.get(); } -Expected<DIInliningInfo> FileAnalysis::symbolizeInlinedCode(uint64_t Address) { +Expected<DIInliningInfo> +FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) { assert(Symbolizer != nullptr && "Symbolizer is invalid."); + return Symbolizer->symbolizeInlinedCode(Object->getFileName(), Address); } @@ -457,13 +460,14 @@ Error FileAnalysis::parseCodeSections() { ArrayRef<uint8_t> SectionBytes((const uint8_t *)SectionContents.data(), Section.getSize()); - parseSectionContents(SectionBytes, Section.getAddress()); + parseSectionContents(SectionBytes, + {Section.getAddress(), Section.getIndex()}); } return Error::success(); } void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes, - uint64_t SectionAddress) { + object::SectionedAddress Address) { assert(Symbolizer && "Symbolizer is uninitialised."); MCInst Instruction; Instr InstrMeta; @@ -477,7 +481,7 @@ void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes, Byte += InstructionSize; - uint64_t VMAddress = SectionAddress + Byte - InstructionSize; + uint64_t VMAddress = Address.Address + Byte - InstructionSize; InstrMeta.Instruction = Instruction; InstrMeta.VMAddress = VMAddress; InstrMeta.InstructionSize = InstructionSize; @@ -509,8 +513,8 @@ void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes, // Check if this instruction exists in the range of the DWARF metadata. if (!IgnoreDWARFFlag) { - auto LineInfo = - Symbolizer->symbolizeCode(Object->getFileName(), VMAddress); + auto LineInfo = Symbolizer->symbolizeCode( + Object->getFileName(), {VMAddress, Address.SectionIndex}); if (!LineInfo) { handleAllErrors(LineInfo.takeError(), [](const ErrorInfoBase &E) { errs() << "Symbolizer failed to get line: " << E.message() << "\n"; @@ -522,7 +526,7 @@ void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes, continue; } - IndirectInstructions.insert(VMAddress); + IndirectInstructions.insert({VMAddress, Address.SectionIndex}); } } |

