[PATCH] D79300: [ELF] Demote lazy symbols relative to a discarded section to Undefined

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 17:15:39 PDT 2020


MaskRay marked 5 inline comments as done.
MaskRay added inline comments.


================
Comment at: lld/ELF/InputFiles.cpp:1124
+      // lazy symbol fetch. We should demote the lazy symbol to an Undefined.
+      if (sym->isLazy() && sym->file->symbols.empty())
+        sym->replace(und);
----------------
grimar wrote:
> I am thinking about adding some flag like `isFetched` or alike to `InputFile` instead of using `symbols.empty()` this and in other places.
> (Or perhaps only for ArchiveFile/LazyObjFile`)
> It should look cleaner and avoid hacks like `push_back(nullptr)`. What do you think?
Thanks. I agree that the usage is subtle. Added a member to ArchiveFile and LazyObjFile, respectively.


================
Comment at: lld/test/ELF/comdat-discarded-lazy.s:18
+# RUN: rm -f %taa.a && llvm-ar rc %taa.a %taa.o
+# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %taa.a -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s
+
----------------
grimar wrote:
> Perhaps `AA`->`BEFORE`, `ZZ`->`AFTER`
It is not clear what the subject and object are when I see `BEFORE` or `AFTER`. I will just stick with `AA` `ZZ`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79300





More information about the llvm-commits mailing list