[llvm] [ObjCopy] Reject compress-debug-sections for non-ELF (PR #191314)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 01:48:01 PDT 2026
https://github.com/nataliakokoromyti updated https://github.com/llvm/llvm-project/pull/191314
>From 70e74ed90d3602f67ca3c172d3e8addaa0f0e22f Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Mon, 27 Apr 2026 16:10:27 -0700
Subject: [PATCH 1/4] reject non-elf compression
---
llvm/lib/ObjCopy/ConfigManager.cpp | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 7424865a2e5e2..dfe60dde66345 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.DecompressDebugSections ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
@@ -50,6 +52,7 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
!Common.SetSectionType.empty() || Common.ExtractDWO ||
Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
Common.StripNonAlloc || Common.StripSections ||
+ Common.CompressionType != DebugCompressionType::None ||
Common.DecompressDebugSections || Common.StripUnneeded ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
@@ -73,8 +76,10 @@ 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.DecompressDebugSections ||
+ Common.CompressionType != DebugCompressionType::None ||
+ 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.DecompressDebugSections || Common.GapFill != 0 ||
+ Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
!Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
return createStringError(
llvm::errc::invalid_argument,
@@ -126,9 +132,10 @@ 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.GapFill != 0 || Common.PadTo != 0 ||
- Common.ChangeSectionLMAValAll != 0 ||
+ Common.StripUnneeded ||
+ Common.CompressionType != DebugCompressionType::None ||
+ Common.DecompressDebugSections || Common.GapFill != 0 ||
+ Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
!Common.ChangeSectionAddress.empty()) {
return createStringError(llvm::errc::invalid_argument,
"option is not supported for DXContainer");
>From fa6746c93fd12ea06667f741939e4e0c8e9a5c51 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Wed, 29 Apr 2026 01:01:15 -0700
Subject: [PATCH 2/4] reject compress-sections too
---
llvm/lib/ObjCopy/ConfigManager.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index dfe60dde66345..bc60b813b2d81 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -31,6 +31,7 @@ Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {
Common.ExtractDWO || Common.StripDWO || Common.StripNonAlloc ||
Common.StripSections || Common.Weaken ||
Common.CompressionType != DebugCompressionType::None ||
+ !Common.compressSections.empty() ||
Common.DecompressDebugSections ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
@@ -53,6 +54,7 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
Common.StripNonAlloc || Common.StripSections ||
Common.CompressionType != DebugCompressionType::None ||
+ !Common.compressSections.empty() ||
Common.DecompressDebugSections || Common.StripUnneeded ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
@@ -78,6 +80,7 @@ Expected<const WasmConfig &> ConfigManager::getWasmConfig() const {
!Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
!Common.SymbolsToRename.empty() || Common.DecompressDebugSections ||
Common.CompressionType != DebugCompressionType::None ||
+ !Common.compressSections.empty() ||
Common.GapFill != 0 || Common.PadTo != 0 ||
Common.ChangeSectionLMAValAll != 0 ||
!Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
@@ -109,6 +112,7 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {
Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
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()) {
@@ -134,6 +138,7 @@ ConfigManager::getDXContainerConfig() const {
Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
Common.StripUnneeded ||
Common.CompressionType != DebugCompressionType::None ||
+ !Common.compressSections.empty() ||
Common.DecompressDebugSections || Common.GapFill != 0 ||
Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
!Common.ChangeSectionAddress.empty()) {
>From 173be7f79bd2e2f6a928f4aaa3aeb8a50d14deb9 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Wed, 29 Apr 2026 03:15:50 -0700
Subject: [PATCH 3/4] fix formatting
---
llvm/lib/ObjCopy/ConfigManager.cpp | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index bc60b813b2d81..9220362eac29b 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -31,8 +31,7 @@ Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {
Common.ExtractDWO || Common.StripDWO || Common.StripNonAlloc ||
Common.StripSections || Common.Weaken ||
Common.CompressionType != DebugCompressionType::None ||
- !Common.compressSections.empty() ||
- Common.DecompressDebugSections ||
+ !Common.compressSections.empty() || Common.DecompressDebugSections ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
@@ -54,8 +53,8 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
Common.StripNonAlloc || Common.StripSections ||
Common.CompressionType != DebugCompressionType::None ||
- !Common.compressSections.empty() ||
- Common.DecompressDebugSections || Common.StripUnneeded ||
+ !Common.compressSections.empty() || Common.DecompressDebugSections ||
+ Common.StripUnneeded ||
Common.DiscardMode == DiscardType::Locals ||
!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
@@ -78,11 +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.DecompressDebugSections ||
- Common.CompressionType != DebugCompressionType::None ||
- !Common.compressSections.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 "
@@ -112,9 +109,8 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {
Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
Common.Weaken || Common.StripUnneeded ||
Common.CompressionType != DebugCompressionType::None ||
- !Common.compressSections.empty() ||
- Common.DecompressDebugSections || Common.GapFill != 0 ||
- Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
+ !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,
@@ -138,9 +134,8 @@ ConfigManager::getDXContainerConfig() const {
Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
Common.StripUnneeded ||
Common.CompressionType != DebugCompressionType::None ||
- !Common.compressSections.empty() ||
- Common.DecompressDebugSections || Common.GapFill != 0 ||
- Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
+ !Common.compressSections.empty() || Common.DecompressDebugSections ||
+ Common.GapFill != 0 || Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
!Common.ChangeSectionAddress.empty()) {
return createStringError(llvm::errc::invalid_argument,
"option is not supported for DXContainer");
>From d7a5ad2890ed6da50f52b29c992cba1e12bd6ee6 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 30 Apr 2026 01:47:48 -0700
Subject: [PATCH 4/4] fix formatting
---
llvm/lib/ObjCopy/ConfigManager.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 9220362eac29b..f68c7b65da297 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -135,7 +135,8 @@ ConfigManager::getDXContainerConfig() const {
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()) {
return createStringError(llvm::errc::invalid_argument,
"option is not supported for DXContainer");
More information about the llvm-commits
mailing list