[PATCH] D135744: [llvm-objcopy] Support --decompress-debug-sections when zlib is disabled
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 11:52:21 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe18b7c7ae0c1: [llvm-objcopy] Support --decompress-debug-sections when zlib is disabled (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135744/new/
https://reviews.llvm.org/D135744
Files:
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/test/tools/llvm-objcopy/ELF/decompress-debug-sections-unsupported-zlib.test
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -993,11 +993,6 @@
"--decompress-debug-sections");
}
- if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
- return createStringError(
- errc::invalid_argument,
- "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
-
if (Config.ExtractPartition && Config.ExtractMainPartition)
return createStringError(errc::invalid_argument,
"cannot specify --extract-partition together with "
Index: llvm/test/tools/llvm-objcopy/ELF/decompress-debug-sections-unsupported-zlib.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/decompress-debug-sections-unsupported-zlib.test
@@ -0,0 +1,18 @@
+# UNSUPPORTED: zlib
+# RUN: yaml2obj %s -o %t
+# RUN: not llvm-objcopy --decompress-debug-sections %t /dev/null 2>&1 | FileCheck %s -DFILE=%t
+
+# CHECK: error: '[[FILE]]': failed to decompress section '.debug_info': LLVM was not built with LLVM_ENABLE_ZLIB or did not find zlib at build time
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .debug_info
+ Flags: [ SHF_COMPRESSED ]
+ AddressAlign: 8
+ Content: "010000000000000001000000000000000100000000000000789c63040000020002"
Index: llvm/lib/ObjCopy/ELF/ELFObject.cpp
===================================================================
--- llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -453,6 +453,11 @@
Twine(Sec.ChType) + ") of section '" +
Sec.Name + "' is unsupported");
}
+ if (auto *Reason =
+ compression::getReasonIfUnsupported(compression::formatFor(Type)))
+ return createStringError(errc::invalid_argument,
+ "failed to decompress section '" + Sec.Name +
+ "': " + Reason);
if (Error E = compression::decompress(Type, Compressed, Decompressed,
static_cast<size_t>(Sec.Size)))
return createStringError(errc::invalid_argument,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135744.467218.patch
Type: text/x-patch
Size: 2432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221012/67ec6d6c/attachment.bin>
More information about the llvm-commits
mailing list