dwarfdump: Deterministically... determine whether parsing a DWARF32 or DWARF64 str_offsets header

Rather than trying one and then the other - use the kind of the CU to
select which kind of header to parse.

llvm-svn: 361589
This commit is contained in:
David Blaikie 2019-05-24 01:41:58 +00:00
parent 8458c9ef42
commit fc302c2b7f
2 changed files with 14 additions and 6 deletions

View File

@ -811,12 +811,19 @@ DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA) {
auto Offset = toSectionOffset(getUnitDIE().find(DW_AT_str_offsets_base), 0);
Optional<StrOffsetsContributionDescriptor> Descriptor;
// Attempt to find a DWARF64 contribution 16 bytes before the base.
if (Offset >= 16)
switch (Header.getFormat()) {
case dwarf::DwarfFormat::DWARF64:
if (Offset < 16)
return None;
Descriptor =
parseDWARF64StringOffsetsTableHeader(DA, (uint32_t)Offset - 16);
// Try to find a DWARF32 contribution 8 bytes before the base.
if (!Descriptor && Offset >= 8)
break;
case dwarf::DwarfFormat::DWARF32:
if (Offset < 8)
return None;
Descriptor = parseDWARF32StringOffsetsTableHeader(DA, (uint32_t)Offset - 8);
break;
}
return Descriptor ? Descriptor->validateContributionSize(DA) : Descriptor;
}

View File

@ -160,18 +160,19 @@ CU1_5_version:
CU1_5_end:
# DWARF v5 CU header
.long CU2_5_end-CU2_5_version # Length of Unit
.long 0xffffffff
.quad CU2_5_end-CU2_5_version # Length of Unit
CU2_5_version:
.short 5 # DWARF version number
.byte 1 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
.long 0 # Offset Into Abbrev. Section
.quad 0 # Offset Into Abbrev. Section
# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
# DW_AT_str_offsets and DW_AT_compdir.
.byte 1 # Abbreviation code
.byte 0 # The index of the producer string
.byte 1 # The index of the CU name string
.long Ldebug_str_offsets_base1-Ldebug_str_offsets
.quad Ldebug_str_offsets_base1-Ldebug_str_offsets
.byte 2 # The index of the comp dir string
.byte 0 # NULL
CU2_5_end: