diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2017-09-26 14:22:35 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2017-09-26 14:22:35 +0000 |
commit | 8af2387b91cfcc1ac152f55307b86d76bbd55170 (patch) | |
tree | 7e7a74bf28f3aec26d8e50a6a2483491d8b50dc0 /llvm/lib | |
parent | dac6fd41704ba16c39584183895079032e7bb99a (diff) | |
download | bcm5719-llvm-8af2387b91cfcc1ac152f55307b86d76bbd55170.tar.gz bcm5719-llvm-8af2387b91cfcc1ac152f55307b86d76bbd55170.zip |
[dwarfdump] Skip 'stripped' sections
When dsymutil generates the companion file, its strips all unnecessary
sections by omitting their body and setting the offset in their
corresponding load command to zero.
One such section is the .eh_frame section, as it contains runtime
information rather than debug information and is part of the __TEXT
segment. When reading this section, we would just read the number of
bytes specified in the load command, starting from offset 0 (i.e. the
beginning of the file).
Rather than trying to parse this obviously invalid section, dwarfdump
now skips this.
Differential revision: https://reviews.llvm.org/D38135
llvm-svn: 314208
Diffstat (limited to 'llvm/lib')
-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 |
3 files changed, 12 insertions, 0 deletions
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)); } |