From: David Blaikie Date: Fri, 24 May 2019 01:41:58 +0000 (+0000) Subject: dwarfdump: Deterministically... determine whether parsing a DWARF32 or DWARF64 str_of... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc302c2b7f1c224be03caba3a82282a943a31519;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 7bc5221..fa165cf 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -811,12 +811,19 @@ DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA) { auto Offset = toSectionOffset(getUnitDIE().find(DW_AT_str_offsets_base), 0); Optional 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; } diff --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s index 1332a94..10a810a 100644 --- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s +++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s @@ -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: