summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-11-22 17:50:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-11-22 17:50:42 +0000
commitde56343cf0bd8190c4e1818a97a234be4919938c (patch)
tree1c6aeb7f28b4ebda5844b424712c35f7db3a2a93
parent7f96c375acaab34d2b314840431b07f13e3b68d0 (diff)
downloadbcm5719-llvm-de56343cf0bd8190c4e1818a97a234be4919938c.tar.gz
bcm5719-llvm-de56343cf0bd8190c4e1818a97a234be4919938c.zip
Simplify as-needed handling.
This is a reduction of a patch by Rui Ueyama. llvm-svn: 318852
-rw-r--r--lld/ELF/InputFiles.cpp2
-rw-r--r--lld/ELF/InputFiles.h4
-rw-r--r--lld/ELF/SymbolTable.cpp4
-rw-r--r--lld/ELF/SyntheticSections.cpp2
-rw-r--r--lld/ELF/Writer.cpp2
5 files changed, 6 insertions, 8 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index e2b46357068..64b38f3dcfe 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -655,7 +655,7 @@ ArchiveFile::getMember(const Archive::Symbol *Sym) {
template <class ELFT>
SharedFile<ELFT>::SharedFile(MemoryBufferRef M, StringRef DefaultSoName)
: ELFFileBase<ELFT>(Base::SharedKind, M), SoName(DefaultSoName),
- AsNeeded(Config->AsNeeded) {}
+ IsNeeded(!Config->AsNeeded) {}
// Partially parse the shared object file so that we can call
// getSoName on this object.
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 5b217d5ba97..834aa73c950 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -320,9 +320,7 @@ public:
std::map<const Elf_Verdef *, NeededVer> VerdefMap;
// Used for --as-needed
- bool AsNeeded = false;
- bool IsUsed = false;
- bool isNeeded() const { return !AsNeeded || IsUsed; }
+ bool IsNeeded;
};
class BinaryFile : public InputFile {
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index c1bd2d1dc1d..e45ce22b500 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -304,7 +304,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, uint8_t Binding,
if (!S->isDefined())
S->Binding = Binding;
if (auto *SS = dyn_cast<SharedSymbol>(S))
- SS->getFile<ELFT>()->IsUsed = true;
+ SS->getFile<ELFT>()->IsNeeded = true;
}
if (auto *L = dyn_cast<Lazy>(S)) {
// An undefined weak will not fetch archive members. See comment on Lazy in
@@ -501,7 +501,7 @@ void SymbolTable::addShared(StringRef Name, SharedFile<ELFT> *File,
if (!WasInserted) {
S->Binding = Binding;
if (!S->isWeak())
- File->IsUsed = true;
+ File->IsNeeded = true;
}
}
}
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index a0b20c719f8..4967333dc00 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -997,7 +997,7 @@ template <class ELFT> void DynamicSection<ELFT>::addEntries() {
InX::DynStrTab->addString(Config->Rpath)});
for (InputFile *File : SharedFiles) {
SharedFile<ELFT> *F = cast<SharedFile<ELFT>>(File);
- if (F->isNeeded())
+ if (F->IsNeeded)
add({DT_NEEDED, InX::DynStrTab->addString(F->SoName)});
}
if (!Config->SoName.empty())
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6a3655a1438..03b531bf46c 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1275,7 +1275,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
if (InX::DynSymTab && Sym->includeInDynsym()) {
InX::DynSymTab->addSymbol(Sym);
if (auto *SS = dyn_cast<SharedSymbol>(Sym))
- if (cast<SharedFile<ELFT>>(Sym->File)->isNeeded())
+ if (cast<SharedFile<ELFT>>(Sym->File)->IsNeeded)
In<ELFT>::VerNeed->addSymbol(SS);
}
}
OpenPOWER on IntegriCloud