[PATCH] D40315: Simplify as-needed handling
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 09:27:50 PST 2017
rafael created this revision.
Herald added subscribers: arichardson, emaste.
Based on https://reviews.llvm.org/D40240 but reduced to be a nop.
https://reviews.llvm.org/D40315
Files:
ELF/InputFiles.cpp
ELF/InputFiles.h
ELF/SymbolTable.cpp
ELF/SyntheticSections.cpp
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1275,7 +1275,7 @@
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);
}
}
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -997,7 +997,7 @@
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())
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -304,7 +304,7 @@
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 @@
if (!WasInserted) {
S->Binding = Binding;
if (!S->isWeak())
- File->IsUsed = true;
+ File->IsNeeded = true;
}
}
}
Index: ELF/InputFiles.h
===================================================================
--- ELF/InputFiles.h
+++ ELF/InputFiles.h
@@ -320,9 +320,7 @@
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 {
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -655,7 +655,7 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40315.123820.patch
Type: text/x-patch
Size: 2504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171121/8d54bbfc/attachment.bin>
More information about the llvm-commits
mailing list