[PATCH] D55902: [ELF] SymbolTable::addShared: don't set IsNeeded unless IsUsedInRegularObj

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 19 15:56:29 PST 2018


MaskRay marked an inline comment as done.
MaskRay added inline comments.


================
Comment at: ELF/SymbolTable.cpp:512-514
+    if (!S->isWeak() && S->IsUsedInRegularObj && !Config->GcSections &&
+        WasUndefined)
       File.IsNeeded = true;
----------------
ruiu wrote:
> Thinking about this code, I'm no longer sure if this code makes sense. If IsNeeded is set correctly for --gc-sections, we can just remove this `if` and let the later pass to set an appropriate bit to IsNeeded, maybe?
This `if` handles the `--no-gc-sections` case. No later passes set the `IsNeeded` bit.
For the `--gc-sections` case, a later pass (`MarkLive.cpp:resolveReloc`) sets the `IsNeeded` bit.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55902/new/

https://reviews.llvm.org/D55902





More information about the llvm-commits mailing list