diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-10-31 14:31:42 +0100 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-11-05 10:21:39 +0100 |
| commit | b4c5b8f3f51206bac2282a8b483e76ad59a5aed5 (patch) | |
| tree | 2540364a5d24115e172f56757711baa7217621b0 /llvm/lib/DebugInfo/DWARF | |
| parent | 0d14656b9d8ca38b8ea321c7047eaeec43c5b2ef (diff) | |
| download | bcm5719-llvm-b4c5b8f3f51206bac2282a8b483e76ad59a5aed5.tar.gz bcm5719-llvm-b4c5b8f3f51206bac2282a8b483e76ad59a5aed5.zip | |
DWARFDebugLoclists: Make it possible to read relocated addresses
Summary:
Handling relocations was not needed when the loclists section was a
DWO-only thing. But since DWARF5, it is possible to use it in regular
objects too, and the standard permits embedding addresses into the
section directly. These addresses need to be relocated in unlinked
files.
Reviewers: JDevlieghere, dblaikie, probinson
Subscribers: aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68271
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 15 |
3 files changed, 17 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index c06d85d5060..c5766b4440d 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -299,12 +299,11 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts, } Header.dump(OS, DumpOpts); - DataExtractor LocData(Data.getData(), - Data.isLittleEndian(), Header.getAddrSize()); DWARFDebugLoclists Loclists; uint64_t EndOffset = Header.length() + Header.getHeaderOffset(); - Loclists.parse(LocData, Offset, EndOffset, Header.getVersion()); + Data.setAddressSize(Header.getAddrSize()); + Loclists.parse(Data, Offset, EndOffset, Header.getVersion()); Loclists.dump(OS, 0, MRI, DumpOpts, DumpOffset); Offset = EndOffset; } @@ -733,7 +732,8 @@ const DWARFDebugLoclists *DWARFContext::getDebugLocDWO() { // Assume all compile units have the same address byte size. // FIXME: We don't need AddressSize for split DWARF since relocatable // addresses cannot appear there. At the moment DWARFExpression requires it. - DataExtractor LocData(DObj->getLocDWOSection().Data, isLittleEndian(), 4); + DWARFDataExtractor LocData(*DObj, DObj->getLocDWOSection(), isLittleEndian(), + 4); // Use version 4. DWO does not support the DWARF v5 .debug_loclists yet and // that means we are parsing the new style .debug_loc (pre-standatized version // of the .debug_loclists). diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp index 4f7b01130a4..032feb9088c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -140,7 +140,7 @@ void DWARFDebugLoc::parse(const DWARFDataExtractor &data) { } Expected<DWARFDebugLoclists::LocationList> -DWARFDebugLoclists::parseOneLocationList(const DataExtractor &Data, +DWARFDebugLoclists::parseOneLocationList(const DWARFDataExtractor &Data, uint64_t *Offset, unsigned Version) { LocationList LL; LL.Offset = *Offset; @@ -165,7 +165,7 @@ DWARFDebugLoclists::parseOneLocationList(const DataExtractor &Data, E.Value1 = Data.getULEB128(C); break; case dwarf::DW_LLE_start_length: - E.Value0 = Data.getAddress(C); + E.Value0 = Data.getRelocatedAddress(C); E.Value1 = Data.getULEB128(C); break; case dwarf::DW_LLE_offset_pair: @@ -173,7 +173,7 @@ DWARFDebugLoclists::parseOneLocationList(const DataExtractor &Data, E.Value1 = Data.getULEB128(C); break; case dwarf::DW_LLE_base_address: - E.Value0 = Data.getAddress(C); + E.Value0 = Data.getRelocatedAddress(C); break; default: cantFail(C.takeError()); @@ -200,7 +200,8 @@ DWARFDebugLoclists::parseOneLocationList(const DataExtractor &Data, return LL; } -void DWARFDebugLoclists::parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version) { +void DWARFDebugLoclists::parse(const DWARFDataExtractor &data, uint64_t Offset, + uint64_t EndOffset, uint16_t Version) { IsLittleEndian = data.isLittleEndian(); AddressSize = data.getAddressSize(); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index cec194e8b6b..f278a7a205e 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -119,13 +119,14 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue, } bool UseLocLists = !U->isDWOUnit(); - StringRef LoclistsSectionData = - UseLocLists ? Obj.getLoclistsSection().Data : U->getLocSectionData(); - - if (!LoclistsSectionData.empty()) { - DataExtractor Data(LoclistsSectionData, Ctx.isLittleEndian(), - Obj.getAddressSize()); - + auto Data = + UseLocLists + ? DWARFDataExtractor(Obj, Obj.getLoclistsSection(), + Ctx.isLittleEndian(), Obj.getAddressSize()) + : DWARFDataExtractor(U->getLocSectionData(), Ctx.isLittleEndian(), + Obj.getAddressSize()); + + if (!Data.getData().empty()) { // Old-style location list were used in DWARF v4 (.debug_loc.dwo section). // Modern locations list (.debug_loclists) are used starting from v5. // Ideally we should take the version from the .debug_loclists section |

