[llvm] eed0242 - DebugInfo: Don't use implicit zero addr_base
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 16:28:32 PST 2019
Author: David Blaikie
Date: 2019-12-18T16:28:19-08:00
New Revision: eed0242330926815d19dd0d54f393576bcffc762
URL: https://github.com/llvm/llvm-project/commit/eed0242330926815d19dd0d54f393576bcffc762
DIFF: https://github.com/llvm/llvm-project/commit/eed0242330926815d19dd0d54f393576bcffc762.diff
LOG: DebugInfo: Don't use implicit zero addr_base
(found when LLVM fails to emit addr_base for gmlt+DWARFv5)
Added:
Modified:
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 36fdd511d1e2..b2ddb7e36b0c 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -210,7 +210,7 @@ class DWARFUnit {
StringRef StringSection;
const DWARFSection &StringOffsetSection;
const DWARFSection *AddrOffsetSection;
- uint32_t AddrOffsetSectionBase = 0;
+ Optional<uint64_t> AddrOffsetSectionBase;
bool isLittleEndian;
bool IsDWO;
const DWARFUnitVector &UnitVector;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 820f530a3e3e..e97ae81345b8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -412,7 +412,7 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
if (A)
dumpSectionedAddress(AddrOS, DumpOpts, *A);
else
- OS << "<no .debug_addr section>";
+ OS << "<unresolved>";
break;
}
case DW_FORM_flag_present:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 02f915bc6f7b..9586d5aca1a9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -228,7 +228,9 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
if (I != R.end() && std::next(I) == R.end())
return (*I)->getAddrOffsetSectionItem(Index);
}
- uint64_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize();
+ if (!AddrOffsetSectionBase)
+ return None;
+ uint64_t Offset = *AddrOffsetSectionBase + Index * getAddressByteSize();
if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
return None;
DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection,
@@ -360,7 +362,7 @@ void DWARFUnit::clear() {
BaseAddr.reset();
RangeSectionBase = 0;
LocSectionBase = 0;
- AddrOffsetSectionBase = 0;
+ AddrOffsetSectionBase = None;
clearDIEs(false);
DWO.reset();
}
@@ -448,13 +450,13 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
Header.setDWOId(*DWOId);
if (!IsDWO) {
- assert(AddrOffsetSectionBase == 0);
+ assert(AddrOffsetSectionBase == None);
assert(RangeSectionBase == 0);
assert(LocSectionBase == 0);
- AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0);
+ AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base));
if (!AddrOffsetSectionBase)
AddrOffsetSectionBase =
- toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
+ toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base));
RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
LocSectionBase = toSectionOffset(UnitDie.find(DW_AT_loclists_base), 0);
}
@@ -578,7 +580,8 @@ bool DWARFUnit::parseDWO() {
return false;
DWO = std::shared_ptr<DWARFCompileUnit>(std::move(DWOContext), DWOCU);
// Share .debug_addr and .debug_ranges section with compile unit in .dwo
- DWO->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);
+ if (AddrOffsetSectionBase)
+ DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase);
if (getVersion() >= 5) {
DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
index e0e468c9153c..ec1ad227bd56 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
@@ -5,17 +5,17 @@
# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_low_pc (0x0000000000000000)
# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000 ".text")
-# FIXME: There is a debug_addr section, it's just that the index is outside its
-# bounds (both of the section, and the range defined by the header for the
-# debug_addr contribution for this CU)
-# CHECK: DW_AT_low_pc (indexed (00000001) address = <no .debug_addr section>)
-# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = <no .debug_addr section>)
+# FIXME: Improve the error message from "unresolved" to describe the specific
+# issue (in this case, the index is outside the bounds of the debug_addr
+# contribution/debug_addr section)
+# CHECK: DW_AT_low_pc (indexed (00000001) address = <unresolved>)
+# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = <unresolved>)
# CHECK: DW_TAG_compile_unit
# FIXME: Should error "no debug_addr contribution" - rather than parsing debug_addr
# from the start, incorrectly interpreting the header bytes as an address.
-# CHECK: DW_AT_low_pc (0x000800050000000c)
-# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x000800050000000c)
+# CHECK: DW_AT_low_pc (indexed (00000000) address = <unresolved>)
+# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = <unresolved>)
.globl foo # -- Begin function foo
foo: # @foo
More information about the llvm-commits
mailing list