llvm.org GIT mirror llvm / deeb5d5
dwarfdump: Add a bit more DWARF64 support This test case was incorrect because it mixed DWARF32 and DWARF64 for a single unit (DWARF32 unit referencing a DWARF64 str_offsets section). So fix enough of the unit parsing for DWARF64 and make the test valid. (not sure if anyone needs DWARF64 support though - support in libDebugInfoDWARF has been added piecemeal and LLVM doesn't produce it at all) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361582 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 5 months ago
4 changed file(s) with 24 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
4747 uint32_t Offset = 0;
4848 // Version, address size, and DWARF format.
4949 dwarf::FormParams FormParams;
50 uint32_t Length = 0;
50 uint64_t Length = 0;
5151 uint64_t AbbrOffset = 0;
5252
5353 // For DWO units only.
8181 uint8_t getDwarfOffsetByteSize() const {
8282 return FormParams.getDwarfOffsetByteSize();
8383 }
84 uint32_t getLength() const { return Length; }
84 uint64_t getLength() const { return Length; }
8585 uint64_t getAbbrOffset() const { return AbbrOffset; }
8686 Optional getDWOId() const { return DWOId; }
8787 void setDWOId(uint64_t Id) {
9696 return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
9797 }
9898 uint8_t getSize() const { return Size; }
99 // FIXME: Support DWARF64.
100 uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
99 uint32_t getNextUnitOffset() const {
100 return Offset + Length +
101 (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) +
102 FormParams.getDwarfOffsetByteSize();
103 }
101104 };
102105
103106 const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
241241 if (!IndexEntry && Index)
242242 IndexEntry = Index->getFromOffset(*offset_ptr);
243243 Length = debug_info.getU32(offset_ptr);
244 // FIXME: Support DWARF64.
244 FormParams.Format = DWARF32;
245245 unsigned SizeOfLength = 4;
246 FormParams.Format = DWARF32;
246 if (Length == 0xffffffff) {
247 Length = debug_info.getU64(offset_ptr);
248 FormParams.Format = DWARF64;
249 SizeOfLength = 8;
250 }
247251 FormParams.Version = debug_info.getU16(offset_ptr);
248252 if (FormParams.Version >= 5) {
249253 UnitType = debug_info.getU8(offset_ptr);
250254 FormParams.AddrSize = debug_info.getU8(offset_ptr);
251 AbbrOffset = debug_info.getU32(offset_ptr);
255 AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
252256 } else {
253 AbbrOffset = debug_info.getRelocatedValue(4, offset_ptr);
257 AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
254258 FormParams.AddrSize = debug_info.getU8(offset_ptr);
255259 // Fake a unit type based on the section type. This isn't perfect,
256260 // but distinguishing compile and type units is generally enough.
9999 bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
100100 uint32_t *Offset, unsigned UnitIndex,
101101 uint8_t &UnitType, bool &isUnitDWARF64) {
102 uint32_t AbbrOffset, Length;
102 uint64_t AbbrOffset, Length;
103103 uint8_t AddrSize = 0;
104104 uint16_t Version;
105105 bool Success = true;
113113 uint32_t OffsetStart = *Offset;
114114 Length = DebugInfoData.getU32(Offset);
115115 if (Length == UINT32_MAX) {
116 Length = DebugInfoData.getU64(Offset);
116117 isUnitDWARF64 = true;
117 OS << format(
118 "Unit[%d] is in 64-bit DWARF format; cannot verify from this point.\n",
119 UnitIndex);
120 return false;
121118 }
122119 Version = DebugInfoData.getU16(Offset);
123120
124121 if (Version >= 5) {
125122 UnitType = DebugInfoData.getU8(Offset);
126123 AddrSize = DebugInfoData.getU8(Offset);
127 AbbrOffset = DebugInfoData.getU32(Offset);
124 AbbrOffset = isUnitDWARF64 ? DebugInfoData.getU64(Offset) : DebugInfoData.getU32(Offset);
128125 ValidType = dwarf::isUnitType(UnitType);
129126 } else {
130127 UnitType = 0;
131 AbbrOffset = DebugInfoData.getU32(Offset);
128 AbbrOffset = isUnitDWARF64 ? DebugInfoData.getU64(Offset) : DebugInfoData.getU32(Offset);
132129 AddrSize = DebugInfoData.getU8(Offset);
133130 }
134131
156153 if (!ValidAddrSize)
157154 note() << "The address size is unsupported.\n";
158155 }
159 *Offset = OffsetStart + Length + 4;
156 *Offset = OffsetStart + Length + (isUnitDWARF64 ? 12 : 4);
160157 return Success;
161158 }
162159
238238 CU1_5_end:
239239
240240 # DWARF v5 CU header
241 .long CU2_5_end-CU2_5_version # Length of Unit
241 .long 0xffffffff
242 .quad CU2_5_end-CU2_5_version # Length of Unit
242243 CU2_5_version:
243244 .short 5 # DWARF version number
244245 .byte 1 # DWARF Unit Type
245246 .byte 8 # Address Size (in bytes)
246 .long .debug_abbrev # Offset Into Abbrev. Section
247 .quad .debug_abbrev # Offset Into Abbrev. Section
247248 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
248249 # DW_AT_str_offsets and DW_AT_compdir.
249250 .byte 1 # Abbreviation code
250251 .byte 0 # The index of the producer string
251252 .byte 1 # The index of the CU name string
252 .long .debug_str_offsets_base1
253 .quad .debug_str_offsets_base1
253254 .byte 2 # The index of the comp dir string
254255 .byte 0 # NULL
255256 CU2_5_end: