[llvm] [llvm-objcopy] Add --compress-sections (PR #85036)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 02:37:32 PDT 2024


================
@@ -215,23 +215,39 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
 }
 
 Error Object::compressOrDecompressSections(const CommonConfig &Config) {
-  // Build a list of the debug sections we are going to replace.
+  // Build a list of sections we are going to replace.
   // We can't call `AddSection` while iterating over sections,
   // because it would mutate the sections array.
   SmallVector<std::pair<SectionBase *, std::function<SectionBase *()>>, 0>
       ToReplace;
   for (SectionBase &Sec : sections()) {
-    if ((Sec.Flags & SHF_ALLOC) || !StringRef(Sec.Name).starts_with(".debug"))
+    std::optional<DebugCompressionType> CType;
+    for (auto &[Matcher, T] : Config.compressSections)
----------------
jh7370 wrote:

A thought: does it make sense to ignore sections specified with `compressSections` if their compression state already matches the requested one? Alternatively, report a specific error for that case? So e.g. if requested to decompress the already decompressed .symtab, we'd either do nothing or emit an error.

https://github.com/llvm/llvm-project/pull/85036


More information about the llvm-commits mailing list