summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2015-10-24 08:52:46 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2015-10-24 08:52:46 +0000
commit5dad7c1d4c41cd7e9ecce648de2c8f3f4226b9cb (patch)
tree9195d65a8274f52b7159fc84df87dd64c1c766d9 /lld/ELF/Writer.cpp
parentb1b67f4daf3e981800ae978068efc94b78087a40 (diff)
downloadbcm5719-llvm-5dad7c1d4c41cd7e9ecce648de2c8f3f4226b9cb.tar.gz
bcm5719-llvm-5dad7c1d4c41cd7e9ecce648de2c8f3f4226b9cb.zip
Reapply r251144: fixed test.
llvm-svn: 251184
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 96fe3acfddf..229d2fe5572 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -99,7 +99,8 @@ template <class ELFT> void lld::elf2::writeResult(SymbolTable<ELFT> *Symtab) {
StringTableSection<ELFT> ShStrTab(".shstrtab", false);
Out<ELFT>::ShStrTab = &ShStrTab;
StringTableSection<ELFT> StrTab(".strtab", false);
- Out<ELFT>::StrTab = &StrTab;
+ if (!Config->StripAll)
+ Out<ELFT>::StrTab = &StrTab;
StringTableSection<ELFT> DynStrTab(".dynstr", true);
Out<ELFT>::DynStrTab = &DynStrTab;
OutputSection<ELFT> Bss(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
@@ -111,8 +112,11 @@ template <class ELFT> void lld::elf2::writeResult(SymbolTable<ELFT> *Symtab) {
Out<ELFT>::GotPlt = &GotPlt;
PltSection<ELFT> Plt;
Out<ELFT>::Plt = &Plt;
- SymbolTableSection<ELFT> SymTab(*Symtab, *Out<ELFT>::StrTab);
- Out<ELFT>::SymTab = &SymTab;
+ std::unique_ptr<SymbolTableSection<ELFT>> SymTab;
+ if (!Config->StripAll) {
+ SymTab.reset(new SymbolTableSection<ELFT>(*Symtab, *Out<ELFT>::StrTab));
+ Out<ELFT>::SymTab = SymTab.get();
+ }
SymbolTableSection<ELFT> DynSymTab(*Symtab, *Out<ELFT>::DynStrTab);
Out<ELFT>::DynSymTab = &DynSymTab;
HashTableSection<ELFT> HashTab;
@@ -288,7 +292,8 @@ template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
StringRef SymName = *SymNameOrErr;
if (!shouldKeepInSymtab<ELFT>(*F, SymName, Sym))
continue;
- Out<ELFT>::SymTab->addLocalSymbol(SymName);
+ if (Out<ELFT>::SymTab)
+ Out<ELFT>::SymTab->addLocalSymbol(SymName);
}
}
}
@@ -513,7 +518,8 @@ template <class ELFT> void Writer<ELFT>::createSections() {
CommonSymbols.push_back(C);
if (!includeInSymtab<ELFT>(*Body))
continue;
- Out<ELFT>::SymTab->addSymbol(Body);
+ if (Out<ELFT>::SymTab)
+ Out<ELFT>::SymTab->addSymbol(Body);
if (isOutputDynamic() && includeInDynamicSymtab(*Body))
Out<ELFT>::DynSymTab->addSymbol(Body);
@@ -522,9 +528,11 @@ template <class ELFT> void Writer<ELFT>::createSections() {
// This order is not the same as the final output order
// because we sort the sections using their attributes below.
- OutputSections.push_back(Out<ELFT>::SymTab);
+ if (Out<ELFT>::SymTab)
+ OutputSections.push_back(Out<ELFT>::SymTab);
OutputSections.push_back(Out<ELFT>::ShStrTab);
- OutputSections.push_back(Out<ELFT>::StrTab);
+ if (Out<ELFT>::StrTab)
+ OutputSections.push_back(Out<ELFT>::StrTab);
if (isOutputDynamic()) {
OutputSections.push_back(Out<ELFT>::DynSymTab);
if (Out<ELFT>::GnuHashTab)
OpenPOWER on IntegriCloud