Index: ELF/InputSection.h =================================================================== --- ELF/InputSection.h +++ ELF/InputSection.h @@ -205,7 +205,6 @@ return llvm::makeArrayRef((const T *)Data.data(), S / sizeof(T)); } -private: // A pointer that owns decompressed data if a section is compressed by zlib. // Since the feature is not used often, this is usually a nullptr. std::unique_ptr DecompressBuf; Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -2495,13 +2495,6 @@ template GdbIndexSection *GdbIndexSection::create() { std::vector Sections = getDebugInfoSections(); - // .debug_gnu_pub{names,types} are useless in executables. - // They are present in input object files solely for creating - // a .gdb_index. So we can remove them from the output. - for (InputSectionBase *S : InputSections) - if (S->Name == ".debug_gnu_pubnames" || S->Name == ".debug_gnu_pubtypes") - S->Live = false; - std::vector Chunks(Sections.size()); std::vector> NameTypes(Sections.size()); @@ -2515,6 +2508,16 @@ NameTypes[I] = readPubNamesAndTypes(Dwarf, I); }); + // .debug_gnu_pub{names,types} are useless in executables. + // They are present in input object files solely for creating + // a .gdb_index. So we can remove them from the output. + for (InputSectionBase *S : InputSections) { + if (S->Name != ".debug_gnu_pubnames" && S->Name != ".debug_gnu_pubtypes") + continue; + S->Live = false; + S->DecompressBuf.reset(); + } + auto *Ret = make(); Ret->Chunks = std::move(Chunks); Ret->Symbols = createSymbols(NameTypes);