diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/DWP/DWP.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/DWP/DWP.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/llvm-project/llvm/lib/DWP/DWP.cpp b/contrib/llvm-project/llvm/lib/DWP/DWP.cpp index 34615a73e328..44e39c019e0c 100644 --- a/contrib/llvm-project/llvm/lib/DWP/DWP.cpp +++ b/contrib/llvm-project/llvm/lib/DWP/DWP.cpp @@ -16,6 +16,7 @@ #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCTargetOptionsCommandFlags.h" #include "llvm/Object/Decompressor.h" +#include "llvm/Object/ELFObjectFile.h" #include "llvm/Support/MemoryBuffer.h" using namespace llvm; @@ -273,12 +274,16 @@ static Error createError(StringRef Name, Error E) { static Error handleCompressedSection(std::deque<SmallString<32>> &UncompressedSections, - StringRef &Name, StringRef &Contents) { - if (!Decompressor::isGnuStyle(Name)) + SectionRef Sec, StringRef Name, StringRef &Contents) { + auto *Obj = dyn_cast<ELFObjectFileBase>(Sec.getObject()); + if (!Obj || + !(static_cast<ELFSectionRef>(Sec).getFlags() & ELF::SHF_COMPRESSED)) return Error::success(); - - Expected<Decompressor> Dec = - Decompressor::create(Name, Contents, false /*IsLE*/, false /*Is64Bit*/); + bool IsLE = isa<object::ELF32LEObjectFile>(Obj) || + isa<object::ELF64LEObjectFile>(Obj); + bool Is64 = isa<object::ELF64LEObjectFile>(Obj) || + isa<object::ELF64BEObjectFile>(Obj); + Expected<Decompressor> Dec = Decompressor::create(Name, Contents, IsLE, Is64); if (!Dec) return createError(Name, Dec.takeError()); @@ -286,7 +291,6 @@ handleCompressedSection(std::deque<SmallString<32>> &UncompressedSections, if (Error E = Dec->resizeAndDecompress(UncompressedSections.back())) return createError(Name, std::move(E)); - Name = Name.substr(2); // Drop ".z" Contents = UncompressedSections.back(); return Error::success(); } @@ -494,7 +498,8 @@ Error handleSection( return ContentsOrErr.takeError(); StringRef Contents = *ContentsOrErr; - if (auto Err = handleCompressedSection(UncompressedSections, Name, Contents)) + if (auto Err = handleCompressedSection(UncompressedSections, Section, Name, + Contents)) return Err; Name = Name.substr(Name.find_first_not_of("._")); |