llvm.org GIT mirror llvm / 4ad9e9b
[dwarfdump] Handle relocations in Dwarf accelerator tables ELF targets (and maybe COFF) use relocations when referring to strings in the .debug_str section. Handle that in the accelerator table dumper. This commit restores the test/DebugInfo/cross-cu-inlining.ll test to its expected platform independant form, validating that the fix works (this test failed on linux boxes). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222029 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
5 changed file(s) with 41 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
9191 OS << " Invalid section offset\n";
9292 continue;
9393 }
94 while (unsigned StringOffset = AccelSection.getU32(&DataOffset)) {
94 while (AccelSection.isValidOffsetForDataOfSize(DataOffset, 4)) {
95 unsigned StringOffset = AccelSection.getU32(&DataOffset);
96 RelocAddrMap::const_iterator Reloc = Relocs.find(DataOffset-4);
97 if (Reloc != Relocs.end())
98 StringOffset += Reloc->second.second;
99 if (!StringOffset)
100 break;
95101 OS << format(" Name: %08x \"%s\"\n", StringOffset,
96102 StringSection.getCStr(&StringOffset));
97103 unsigned NumData = AccelSection.getU32(&DataOffset);
0
1 #include "DWARFRelocMap.h"
2
13 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/DebugInfo/DWARFFormValue.h"
2628 struct HeaderData HdrData;
2729 DataExtractor AccelSection;
2830 DataExtractor StringSection;
31 const RelocAddrMap& Relocs;
2932 public:
30 DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection)
31 : AccelSection(AccelSection), StringSection(StringSection) {}
33 DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection,
34 const RelocAddrMap &Relocs)
35 : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {}
3236
3337 bool extract();
3438 void dump(raw_ostream &OS);
5959 }
6060 }
6161
62 static void dumpAccelSection(raw_ostream &OS, StringRef Name, StringRef Data,
63 StringRef StringSection, bool LittleEndian) {
64 DataExtractor AccelSection(Data, LittleEndian, 0);
62 static void dumpAccelSection(raw_ostream &OS, StringRef Name,
63 const DWARFSection& Section, StringRef StringSection,
64 bool LittleEndian) {
65 DataExtractor AccelSection(Section.Data, LittleEndian, 0);
6566 DataExtractor StrData(StringSection, LittleEndian, 0);
6667 OS << "\n." << Name << " contents:\n";
67 DWARFAcceleratorTable Accel(AccelSection, StrData);
68 DWARFAcceleratorTable Accel(AccelSection, StrData, Section.Relocs);
6869 if (!Accel.extract())
6970 return;
7071 Accel.dump(OS);
592593 .Case("debug_str.dwo", &StringDWOSection)
593594 .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
594595 .Case("debug_addr", &AddrSection)
595 .Case("apple_names", &AppleNamesSection)
596 .Case("apple_types", &AppleTypesSection)
597 .Case("apple_namespaces", &AppleNamespacesSection)
598 .Case("apple_namespac", &AppleNamespacesSection)
599 .Case("apple_objc", &AppleObjCSection)
596 .Case("apple_names", &AppleNamesSection.Data)
597 .Case("apple_types", &AppleTypesSection.Data)
598 .Case("apple_namespaces", &AppleNamespacesSection.Data)
599 .Case("apple_namespac", &AppleNamespacesSection.Data)
600 .Case("apple_objc", &AppleObjCSection.Data)
600601 // Any more debug info sections go here.
601602 .Default(nullptr);
602603 if (SectionData) {
629630 .Case("debug_loc", &LocSection.Relocs)
630631 .Case("debug_info.dwo", &InfoDWOSection.Relocs)
631632 .Case("debug_line", &LineSection.Relocs)
633 .Case("apple_names", &AppleNamesSection.Relocs)
634 .Case("apple_types", &AppleTypesSection.Relocs)
635 .Case("apple_namespaces", &AppleNamespacesSection.Relocs)
636 .Case("apple_namespac", &AppleNamespacesSection.Relocs)
637 .Case("apple_objc", &AppleObjCSection.Relocs)
632638 .Default(nullptr);
633639 if (!Map) {
634640 // Find debug_types relocs by section rather than name as there are
191191 virtual StringRef getStringOffsetDWOSection() = 0;
192192 virtual StringRef getRangeDWOSection() = 0;
193193 virtual StringRef getAddrSection() = 0;
194 virtual StringRef getAppleNamesSection() = 0;
195 virtual StringRef getAppleTypesSection() = 0;
196 virtual StringRef getAppleNamespacesSection() = 0;
197 virtual StringRef getAppleObjCSection() = 0;
194 virtual const DWARFSection& getAppleNamesSection() = 0;
195 virtual const DWARFSection& getAppleTypesSection() = 0;
196 virtual const DWARFSection& getAppleNamespacesSection() = 0;
197 virtual const DWARFSection& getAppleObjCSection() = 0;
198198
199199 static bool isSupportedVersion(unsigned version) {
200200 return version == 2 || version == 3 || version == 4;
239239 StringRef StringOffsetDWOSection;
240240 StringRef RangeDWOSection;
241241 StringRef AddrSection;
242 StringRef AppleNamesSection;
243 StringRef AppleTypesSection;
244 StringRef AppleNamespacesSection;
245 StringRef AppleObjCSection;
242 DWARFSection AppleNamesSection;
243 DWARFSection AppleTypesSection;
244 DWARFSection AppleNamespacesSection;
245 DWARFSection AppleObjCSection;
246246
247247 SmallVector, 4> UncompressedSections;
248248
263263 StringRef getPubTypesSection() override { return PubTypesSection; }
264264 StringRef getGnuPubNamesSection() override { return GnuPubNamesSection; }
265265 StringRef getGnuPubTypesSection() override { return GnuPubTypesSection; }
266 StringRef getAppleNamesSection() override { return AppleNamesSection; }
267 StringRef getAppleTypesSection() override { return AppleTypesSection; }
268 StringRef getAppleNamespacesSection() override { return AppleNamespacesSection; }
269 StringRef getAppleObjCSection() override { return AppleObjCSection; }
266 const DWARFSection& getAppleNamesSection() override { return AppleNamesSection; }
267 const DWARFSection& getAppleTypesSection() override { return AppleTypesSection; }
268 const DWARFSection& getAppleNamespacesSection() override { return AppleNamespacesSection; }
269 const DWARFSection& getAppleObjCSection() override { return AppleObjCSection; }
270270
271271 // Sections for DWARF5 split dwarf proposal.
272272 const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; }
0 ; REQUIRES: object-emission
11
22 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck -implicit-check-not=DW_TAG %s
3 ; RUN: %llc_dwarf -mtriple x86_64-apple-darwin -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
3 ; RUN: %llc_dwarf -dwarf-accel-tables=Enable -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
44
55 ; Build from source:
66 ; $ clang++ a.cpp b.cpp -g -c -emit-llvm