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

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 01:54:32 PDT 2026


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

>From f4b4a67de0617d059e0ddd51f164de2c39216142 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 30 Apr 2026 01:50:27 -0700
Subject: [PATCH 1/2] reject non-elf compression

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

diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 7424865a2e5e2..f68c7b65da297 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,7 +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.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 ||
@@ -73,8 +77,9 @@ 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,9 +107,10 @@ 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.GapFill != 0 || Common.PadTo != 0 ||
-      Common.ChangeSectionLMAValAll != 0 ||
+      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()) {
     return createStringError(
         llvm::errc::invalid_argument,
@@ -126,7 +132,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()) {

>From fb2bbfb015684c493855d47f4c096a7f2fdce286 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 30 Apr 2026 01:54:19 -0700
Subject: [PATCH 2/2] fix formatting

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

diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index f68c7b65da297..403b9d1bb922e 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -54,8 +54,7 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
       Common.StripNonAlloc || Common.StripSections ||
       Common.CompressionType != DebugCompressionType::None ||
       !Common.compressSections.empty() || Common.DecompressDebugSections ||
-      Common.StripUnneeded ||
-      Common.DiscardMode == DiscardType::Locals ||
+      Common.StripUnneeded || Common.DiscardMode == DiscardType::Locals ||
       !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
@@ -77,9 +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.CompressionType != DebugCompressionType::None ||
+      !Common.SymbolsToRename.empty() ||
+      Common.CompressionType != DebugCompressionType::None ||
       !Common.compressSections.empty() || Common.DecompressDebugSections ||
-      Common.GapFill != 0 || Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
+      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 "
@@ -110,7 +111,8 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {
       Common.Weaken || Common.StripUnneeded ||
       Common.CompressionType != DebugCompressionType::None ||
       !Common.compressSections.empty() || Common.DecompressDebugSections ||
-      Common.GapFill != 0 || Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
+      Common.GapFill != 0 || Common.PadTo != 0 ||
+      Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
     return createStringError(
         llvm::errc::invalid_argument,



More information about the llvm-commits mailing list