From: David Blaikie Date: Sat, 22 Dec 2018 22:20:40 +0000 (+0000) Subject: DebugInfo: Accurately propagate the section used by a relocation when accessing range... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9c8ee7d5360774895ef41c222c7a6d924e5bb8e;p=llvm DebugInfo: Accurately propagate the section used by a relocation when accessing ranges defined by low/high_pc This is difficult/not possible to test in LLVM, but is visible as a crash in LLD when parsing DWARF to generate gdb-index. This function is called by llvm-dwarfdump when parsing high_pc for non-verbose output (to print the actual high_pc rather than the low_pc relative value), but in that case llvm-dwarfdump doesn't print section names (if it did, it would hit this problem). We could add some other features to llvm-dwarfdump to expose this, but nothing really springs to my mind. I will add a test to lld, though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350010 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h index ed34d3c21de..727e853c09f 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -61,7 +61,6 @@ public: dwarf::Form getForm() const { return Form; } uint64_t getRawUValue() const { return Value.uval; } - uint64_t getSectionIndex() const { return Value.SectionIndex; } void setForm(dwarf::Form F) { Form = F; } void setUValue(uint64_t V) { Value.uval = V; } void setSValue(int64_t V) { Value.sval = V; } diff --git a/lib/DebugInfo/DWARF/DWARFDie.cpp b/lib/DebugInfo/DWARF/DWARFDie.cpp index fd692ab519c..81ef0c8c7ae 100644 --- a/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -466,13 +466,13 @@ Optional DWARFDie::getHighPC(uint64_t LowPC) const { bool DWARFDie::getLowAndHighPC(uint64_t &LowPC, uint64_t &HighPC, uint64_t &SectionIndex) const { auto F = find(DW_AT_low_pc); - auto LowPcAddr = toAddress(F); + auto LowPcAddr = toSectionedAddress(F); if (!LowPcAddr) return false; - if (auto HighPcAddr = getHighPC(*LowPcAddr)) { - LowPC = *LowPcAddr; + if (auto HighPcAddr = getHighPC(LowPcAddr->Address)) { + LowPC = LowPcAddr->Address; HighPC = *HighPcAddr; - SectionIndex = F->getSectionIndex(); + SectionIndex = LowPcAddr->SectionIndex; return true; } return false;