[llvm] [ObjCopy] Reject compress-debug-sections for non-ELF (PR #191314)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 01:56:29 PDT 2026


https://github.com/nataliakokoromyti updated https://github.com/llvm/llvm-project/pull/191314

>From 070aea9efca611c42b122142edee57e61b4ca77f Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 30 Apr 2026 01:56:18 -0700
Subject: [PATCH] reject non-elf compression

---
 llvm/lib/ObjCopy/ConfigManager.cpp | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 7424865a2e5e2..403b9d1bb922e 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -29,7 +29,9 @@ Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {
       !Common.SymbolsToKeepGlobal.empty() || !Common.SectionsToRename.empty() ||
       !Common.SetSectionAlignment.empty() || !Common.SetSectionType.empty() ||
       Common.ExtractDWO || Common.StripDWO || Common.StripNonAlloc ||
-      Common.StripSections || Common.Weaken || Common.DecompressDebugSections ||
+      Common.StripSections || Common.Weaken ||
+      Common.CompressionType != DebugCompressionType::None ||
+      !Common.compressSections.empty() || Common.DecompressDebugSections ||
       Common.DiscardMode == DiscardType::Locals ||
       !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
@@ -50,8 +52,9 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
       !Common.SetSectionType.empty() || Common.ExtractDWO ||
       Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
       Common.StripNonAlloc || Common.StripSections ||
-      Common.DecompressDebugSections || Common.StripUnneeded ||
-      Common.DiscardMode == DiscardType::Locals ||
+      Common.CompressionType != DebugCompressionType::None ||
+      !Common.compressSections.empty() || Common.DecompressDebugSections ||
+      Common.StripUnneeded || Common.DiscardMode == DiscardType::Locals ||
       !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
@@ -73,8 +76,11 @@ Expected<const WasmConfig &> ConfigManager::getWasmConfig() const {
       !Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
       !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
       !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
-      !Common.SymbolsToRename.empty() || Common.GapFill != 0 ||
-      Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
+      !Common.SymbolsToRename.empty() ||
+      Common.CompressionType != DebugCompressionType::None ||
+      !Common.compressSections.empty() || Common.DecompressDebugSections ||
+      Common.GapFill != 0 || Common.PadTo != 0 ||
+      Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
     return createStringError(llvm::errc::invalid_argument,
                              "only flags for section dumping, removal, and "
@@ -102,7 +108,9 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {
       Common.ExtractMainPartition || Common.OnlyKeepDebug ||
       Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
       Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
-      Common.Weaken || Common.StripUnneeded || Common.DecompressDebugSections ||
+      Common.Weaken || Common.StripUnneeded ||
+      Common.CompressionType != DebugCompressionType::None ||
+      !Common.compressSections.empty() || Common.DecompressDebugSections ||
       Common.GapFill != 0 || Common.PadTo != 0 ||
       Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
@@ -126,7 +134,9 @@ ConfigManager::getDXContainerConfig() const {
       !Common.SetSectionType.empty() || Common.ExtractDWO ||
       Common.OnlyKeepDebug || Common.StripAllGNU || Common.StripDWO ||
       Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
-      Common.StripUnneeded || Common.DecompressDebugSections ||
+      Common.StripUnneeded ||
+      Common.CompressionType != DebugCompressionType::None ||
+      !Common.compressSections.empty() || Common.DecompressDebugSections ||
       Common.GapFill != 0 || Common.PadTo != 0 ||
       Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty()) {



More information about the llvm-commits mailing list