[llvm] [llvm-objcopy] Add --compress-sections (PR #85036)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 02:37:32 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")) {
----------------
jh7370 wrote:
Perhaps worth a brief comment clarifying the purpose of this block (i.e. handle the old debug section compression options).
https://github.com/llvm/llvm-project/pull/85036
More information about the llvm-commits
mailing list