aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorMitch Phillips <mitchp@google.com>2024-04-05 10:59:32 +0200
committerMitch Phillips <mitchp@google.com>2024-04-05 11:42:52 +0200
commitbe8bc3cf43f07f68d89c82db45e29f63b432ceb5 (patch)
treee83317a1f458f90e5ce96c98d8ef39963dbdd98d /llvm/lib
parent163301d785a7e6b45d25a4060a239d6af72d6ae6 (diff)
downloadllvm-be8bc3cf43f07f68d89c82db45e29f63b432ceb5.zip
llvm-be8bc3cf43f07f68d89c82db45e29f63b432ceb5.tar.gz
llvm-be8bc3cf43f07f68d89c82db45e29f63b432ceb5.tar.bz2
Revert "[llvm-objcopy] Add --compress-sections"
This reverts commit 9e3b64b9f95aadf57568576712902a272fe66503. Reason: Broke the UBSan buildbot. See the comments in the pull request (https://github.com/llvm/llvm-project/pull/85036) for more information.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index f343d14..205bc1e 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -215,41 +215,23 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
}
Error Object::compressOrDecompressSections(const CommonConfig &Config) {
- // Build a list of sections we are going to replace.
- // We can't call `addSection` while iterating over sections,
+ // Build a list of the debug 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()) {
- std::optional<DebugCompressionType> CType;
- for (auto &[Matcher, T] : Config.compressSections)
- if (Matcher.matches(Sec.Name))
- CType = T;
- // Handle --compress-debug-sections and --decompress-debug-sections, which
- // apply to non-ALLOC debug sections.
- if (!(Sec.Flags & SHF_ALLOC) && StringRef(Sec.Name).starts_with(".debug")) {
- if (Config.CompressionType != DebugCompressionType::None)
- CType = Config.CompressionType;
- else if (Config.DecompressDebugSections)
- CType = DebugCompressionType::None;
- }
- if (!CType)
+ if ((Sec.Flags & SHF_ALLOC) || !StringRef(Sec.Name).starts_with(".debug"))
continue;
-
- if (Sec.ParentSegment)
- return createStringError(
- errc::invalid_argument,
- "section '" + Sec.Name +
- "' within a segment cannot be (de)compressed");
-
if (auto *CS = dyn_cast<CompressedSection>(&Sec)) {
- if (*CType == DebugCompressionType::None)
+ if (Config.DecompressDebugSections) {
ToReplace.emplace_back(
&Sec, [=] { return &addSection<DecompressedSection>(*CS); });
- } else if (*CType != DebugCompressionType::None) {
- ToReplace.emplace_back(&Sec, [=, S = &Sec] {
+ }
+ } else if (Config.CompressionType != DebugCompressionType::None) {
+ ToReplace.emplace_back(&Sec, [&, S = &Sec] {
return &addSection<CompressedSection>(
- CompressedSection(*S, *CType, Is64Bits));
+ CompressedSection(*S, Config.CompressionType, Is64Bits));
});
}
}