[PATCH] D35339: Delay removal of pubtypes and pubnames
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 17:10:51 PDT 2017
rafael created this revision.
Herald added a subscriber: emaste.
The reason for this is that I want to use the lld infrastructure for getting data and relocations.
This means that the data for .debug_gnu_pubnames will be just a InputSection->Data, which means we have to at least create a InputSection.
https://reviews.llvm.org/D35339
Files:
ELF/InputFiles.cpp
ELF/SyntheticSections.cpp
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1760,12 +1760,24 @@
return Ret;
}
-static std::vector<InputSection *> getDebugInfoSections() {
+static std::vector<InputSection *> filterForGdbIndex() {
std::vector<InputSection *> Ret;
- for (InputSectionBase *S : InputSections)
- if (InputSection *IS = dyn_cast<InputSection>(S))
- if (IS->Name == ".debug_info")
- Ret.push_back(IS);
+ for (InputSectionBase *S : InputSections) {
+ InputSection *IS = dyn_cast<InputSection>(S);
+ if (!IS)
+ continue;
+ StringRef Name = IS->Name;
+ if (Name == ".debug_info")
+ Ret.push_back(IS);
+
+ // If -gdb-index is given, LLD creates .gdb_index section, and that
+ // section serves the same purpose as .debug_gnu_pub{names,types} sections.
+ // If that's the case, we want to eliminate .debug_gnu_pub{names,types}
+ // because they are redundant and can waste large amount of disk space
+ // (for example, they are about 400 MiB in total for a clang debug build.)
+ if (Name == ".debug_gnu_pubnames" || Name == ".debug_gnu_pubtypes")
+ Script->discard({S});
+ }
return Ret;
}
@@ -1809,7 +1821,7 @@
template <class ELFT> GdbIndexSection *elf::createGdbIndex() {
std::vector<GdbIndexChunk> Chunks;
- for (InputSection *Sec : getDebugInfoSections()) {
+ for (InputSection *Sec : filterForGdbIndex()) {
InputFile *F = Sec->File;
std::error_code EC;
ELFObjectFile<ELFT> Obj(F->MB, EC);
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -501,15 +501,6 @@
if (Config->Strip != StripPolicy::None && Name.startswith(".debug"))
return &InputSection::Discarded;
- // If -gdb-index is given, LLD creates .gdb_index section, and that
- // section serves the same purpose as .debug_gnu_pub{names,types} sections.
- // If that's the case, we want to eliminate .debug_gnu_pub{names,types}
- // because they are redundant and can waste large amount of disk space
- // (for example, they are about 400 MiB in total for a clang debug build.)
- if (Config->GdbIndex &&
- (Name == ".debug_gnu_pubnames" || Name == ".debug_gnu_pubtypes"))
- return &InputSection::Discarded;
-
// The linkonce feature is a sort of proto-comdat. Some glibc i386 object
// files contain definitions of symbol "__x86.get_pc_thunk.bx" in linkonce
// sections. Drop those sections to avoid duplicate symbol errors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35339.106354.patch
Type: text/x-patch
Size: 2604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170713/5e3089cb/attachment.bin>
More information about the llvm-commits
mailing list