[PATCH] D59018: [llvm-objdump] - Fix incorrect CompressedSection creation.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 03:07:21 PST 2019
grimar created this revision.
grimar added a reviewer: jhenderson.
Herald added subscribers: jdoerfert, MaskRay, jakehehrlich, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
grimar edited the summary of this revision.
We should create `CompressedSection` only if the section has `SHF_COMPRESSED` flag
or it's name starts from '.zdebug'. Currently, we create it if data starts from `ZLIB` signature.
As a result, if you call `isa<CompressedSection>` on a section created, it would return false,
because `classof` checks the section name and not the `ZLIB` signature (what is correct):
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/Object.h#L384
There is no test, as because of broken `isa` described such sections are handled as uncompressed:
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/Object.cpp#L237
So patch does not change the behavior observed but allows to create the correct sections
from start.
https://reviews.llvm.org/D59018
Files:
tools/llvm-objcopy/ELF/Object.cpp
Index: tools/llvm-objcopy/ELF/Object.cpp
===================================================================
--- tools/llvm-objcopy/ELF/Object.cpp
+++ tools/llvm-objcopy/ELF/Object.cpp
@@ -1111,7 +1111,8 @@
default: {
Data = unwrapOrError(ElfFile.getSectionContents(&Shdr));
- if (isDataGnuCompressed(Data) || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) {
+ StringRef Name = unwrapOrError(ElfFile.getSectionName(&Shdr));
+ if (Name.startswith(".zdebug") || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) {
uint64_t DecompressedSize, DecompressedAlign;
std::tie(DecompressedSize, DecompressedAlign) =
getDecompressedSizeAndAlignment<ELFT>(Data);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59018.189469.patch
Type: text/x-patch
Size: 676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190306/d54ba3ac/attachment.bin>
More information about the llvm-commits
mailing list