diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Object/MachO.h | 10 | ||||
-rw-r--r-- | llvm/include/llvm/Object/ObjectFile.h | 6 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Object/ObjectFile.cpp | 2 | ||||
-rw-r--r-- | llvm/test/tools/llvm-dwarfdump/X86/Inputs/empty.dSYM | bin | 0 -> 4098 bytes | |||
-rw-r--r-- | llvm/test/tools/llvm-dwarfdump/X86/stripped.test | 11 |
7 files changed, 39 insertions, 0 deletions
diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index a4ecc51a6fa..03fd52fb482 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -310,6 +310,16 @@ public: bool isSectionBSS(DataRefImpl Sec) const override; bool isSectionVirtual(DataRefImpl Sec) const override; bool isSectionBitcode(DataRefImpl Sec) const override; + + /// When dsymutil generates the companion file, it strips all unnecessary + /// sections (e.g. everything in the _TEXT segment) by omitting their body + /// and setting the offset in their corresponding load command to zero. + /// + /// While the load command itself is valid, reading the section corresponds + /// to reading the number of bytes specified in the load command, starting + /// from offset 0 (i.e. the Mach-O header at the beginning of the file). + bool isSectionStripped(DataRefImpl Sec) const override; + relocation_iterator section_rel_begin(DataRefImpl Sec) const override; relocation_iterator section_rel_end(DataRefImpl Sec) const override; diff --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h index 867c218c2a9..57496373973 100644 --- a/llvm/include/llvm/Object/ObjectFile.h +++ b/llvm/include/llvm/Object/ObjectFile.h @@ -109,6 +109,7 @@ public: bool isBSS() const; bool isVirtual() const; bool isBitcode() const; + bool isStripped() const; bool containsSymbol(SymbolRef S) const; @@ -236,6 +237,7 @@ protected: // A section is 'virtual' if its contents aren't present in the object image. virtual bool isSectionVirtual(DataRefImpl Sec) const = 0; virtual bool isSectionBitcode(DataRefImpl Sec) const; + virtual bool isSectionStripped(DataRefImpl Sec) const; virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0; virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0; virtual section_iterator getRelocatedSection(DataRefImpl Sec) const; @@ -442,6 +444,10 @@ inline bool SectionRef::isBitcode() const { return OwningObject->isSectionBitcode(SectionPimpl); } +inline bool SectionRef::isStripped() const { + return OwningObject->isSectionStripped(SectionPimpl); +} + inline relocation_iterator SectionRef::relocation_begin() const { return OwningObject->section_rel_begin(SectionPimpl); } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 59cf636e604..156c65ad92a 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -1135,6 +1135,10 @@ public: if (Section.isBSS() || Section.isVirtual()) continue; + // Skip sections stripped by dsymutil. + if (Section.isStripped()) + continue; + StringRef Data; section_iterator RelocatedSection = Section.getRelocatedSection(); // Try to obtain an already relocated version of this section. diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index b943c4063d6..7b4be973a09 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -1928,6 +1928,12 @@ bool MachOObjectFile::isSectionBitcode(DataRefImpl Sec) const { return false; } +bool MachOObjectFile::isSectionStripped(DataRefImpl Sec) const { + if (is64Bit()) + return getSection64(Sec).offset == 0; + return getSection(Sec).offset == 0; +} + relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const { DataRefImpl Ret; Ret.d.a = Sec.d.a; diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index 67818409986..2b80d0bf538 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -75,6 +75,8 @@ bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const { return false; } +bool ObjectFile::isSectionStripped(DataRefImpl Sec) const { return false; } + section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { return section_iterator(SectionRef(Sec, this)); } diff --git a/llvm/test/tools/llvm-dwarfdump/X86/Inputs/empty.dSYM b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/empty.dSYM Binary files differnew file mode 100644 index 00000000000..5f7962d2e4f --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/empty.dSYM diff --git a/llvm/test/tools/llvm-dwarfdump/X86/stripped.test b/llvm/test/tools/llvm-dwarfdump/X86/stripped.test new file mode 100644 index 00000000000..1eaf1925105 --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/X86/stripped.test @@ -0,0 +1,11 @@ +RUN: llvm-dwarfdump -debug-frame %S/Inputs/empty.dSYM | FileCheck %s + +You can generate an empty dSYM companion file by invoking dsymutil on any +object file. + +CHECK: .debug_frame contents: +CHECK-NOT: CIE +CHECK-NOT: FDE +CHECK: .eh_frame contents: +CHECK-NOT: CIE +CHECK-NOT: FDE |