[llvm] [llvm-objcopy] Add --compress-sections (PR #85036)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 20:42:54 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)
+ if (Matcher.matches(Sec.Name))
+ CType = T;
+ if (!(Sec.Flags & SHF_ALLOC) && StringRef(Sec.Name).starts_with(".debug")) {
----------------
MaskRay wrote:
Added!
https://github.com/llvm/llvm-project/pull/85036
More information about the llvm-commits
mailing list