diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-28 20:17:58 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-11-28 20:17:58 +0000 |
commit | 2df1188fdb6ab81d60248bb497d7040b8eb3700c (patch) | |
tree | a03aec6fb3fd6469994ce72d4b5e932da2e0fdb4 /lld/ELF/MarkLive.cpp | |
parent | 0a6b24f9002c44b2d716340b8da44933a52c50c1 (diff) |
Bring back r319008.
This includes a fix to mark copy reloc aliases as used.
Original message:
[ELF] Do not keep symbols if they referenced only from discarded sections.
This patch also ensures that in case of "--as-needed" is used,
DT_NEEDED entries are not created if they are required only by
these eliminated symbols.
Diffstat (limited to 'lld/ELF/MarkLive.cpp')
-rw-r--r-- | lld/ELF/MarkLive.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 3520abeff37..e619a955b7f 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -64,6 +64,12 @@ static void resolveReloc(InputSectionBase &Sec, RelT &Rel, std::function<void(InputSectionBase *, uint64_t)> Fn) { Symbol &B = Sec.getFile<ELFT>()->getRelocTargetSym(Rel); + // If a symbol is referenced in a live section, it is used. + B.Used = true; + if (auto *SS = dyn_cast<SharedSymbol>(&B)) + if (!SS->isWeak()) + SS->getFile<ELFT>()->IsNeeded = true; + if (auto *D = dyn_cast<Defined>(&B)) { if (!D->Section) return; |