summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-04-26 13:56:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-04-26 13:56:26 +0000
commit0baa73f3175f7f8f86954fad67efd9110ff9c6b2 (patch)
treeef6d02914bc1bcbe918f7c97146160fd5b2bb6ac /lld/ELF/Writer.cpp
parent75f0b3fe86e856a332fa60ee256e84eb4061dcc6 (diff)
downloadbcm5719-llvm-0baa73f3175f7f8f86954fad67efd9110ff9c6b2.tar.gz
bcm5719-llvm-0baa73f3175f7f8f86954fad67efd9110ff9c6b2.zip
Handle --as-needed with symbols, not relocations.
This matches the behavior of both gold and bfd. llvm-svn: 267558
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 9ee44dcc55a..bf2a4dc2ce8 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -521,9 +521,7 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {
const RelTy &RI = *I;
uint32_t SymIndex = RI.getSymbol(Config->Mips64EL);
- SymbolBody &OrigBody = File.getSymbolBody(SymIndex);
- Symbol *Sym = OrigBody.Backref;
- SymbolBody &Body = Sym ? *Sym->Body : OrigBody;
+ SymbolBody &Body = File.getSymbolBody(SymIndex).repl();
uint32_t Type = RI.getType(Config->Mips64EL);
// Ignore "hint" relocation because it is for optional code optimization.
@@ -534,11 +532,6 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
if (Offset == (uintX_t)-1)
continue;
- // Set "used" bit for --as-needed.
- if (OrigBody.isUndefined() && Sym && !Sym->isWeak())
- if (auto *S = dyn_cast<SharedSymbol<ELFT>>(&Body))
- S->File->IsUsed = true;
-
RelExpr Expr = Target->getRelExpr(Type, Body);
// This relocation does not require got entry, but it is relative to got and
@@ -1344,6 +1337,12 @@ template <class ELFT> void Writer<ELFT>::createSections() {
std::vector<DefinedCommon *> CommonSymbols;
for (Symbol *S : Symtab.getSymbols()) {
SymbolBody *Body = S->Body;
+
+ // Set "used" bit for --as-needed.
+ if (S->IsUsedInRegularObj && !S->isWeak())
+ if (auto *SS = dyn_cast<SharedSymbol<ELFT>>(Body))
+ SS->File->IsUsed = true;
+
if (Body->isUndefined() && !S->isWeak()) {
auto *U = dyn_cast<UndefinedElf<ELFT>>(Body);
if (!U || !U->canKeepUndefined())
OpenPOWER on IntegriCloud