[llvm] r361589 - dwarfdump: Deterministically... determine whether parsing a DWARF32 or DWARF64 str_offsets header
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 18:41:58 PDT 2019
Author: dblaikie
Date: Thu May 23 18:41:58 2019
New Revision: 361589
URL: http://llvm.org/viewvc/llvm-project?rev=361589&view=rev
Log:
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.
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=361589&r1=361588&r2=361589&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Thu May 23 18:41:58 2019
@@ -811,12 +811,19 @@ DWARFUnit::determineStringOffsetsTableCo
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;
}
Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s?rev=361589&r1=361588&r2=361589&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s Thu May 23 18:41:58 2019
@@ -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:
More information about the llvm-commits
mailing list