Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -2428,9 +2428,10 @@ // .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; + if (!Config->Relocatable) + 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());