forked from OSchip/llvm-project
DebugInfo: Don't use implicit zero addr_base
(found when LLVM fails to emit addr_base for gmlt+DWARFv5)
This commit is contained in:
parent
64fa76ef55
commit
eed0242330
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue