[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
Sat May 2 19:04:55 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, psmith, rprichard, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay marked an inline comment as done.
MaskRay added inline comments.
================
Comment at: lld/ELF/InputFiles.cpp:1588
+ // symbols is in a valid but unspecified state. Make it empty and inform a
+ // future invocation of ObjFile<ELFT>::initializeSymbols() that this
+ // LazyObjFile has been processed.
----------------
s/has been processed/is being fetched/
Fixes PR45594.
In `ObjFile<ELFT>::initializeSymbols()`, for a defined symbol relative to
a discarded section (due to section group rules), it may have been
inserted as a lazy symbol. We need to demote it to an Undefined to
enable the `discarded section` error happened in a later pass.
Use the emptiness of `file->symbols` to represent that there is an
ongoing lazy symbol fetch and we should replace the current lazy symbol
with an Undefined, instead of calling `Symbol::resolve` (the lazy symbol
was added by an unrelated archive/lazy object).
As a side result, one small issue in start-lib-comdat.s is now fixed.
The hack motivating D51892 <https://reviews.llvm.org/D51892> will be unsupported: if
`.gnu.linkonce.t.__i686.get_pc_thunk.bx` is in an archive is referenced
by another section, this will likely be errored unless the function is
also defined in a regular object file.
(Bringing back rL330869 <https://reviews.llvm.org/rL330869> would error `undefined symbol` instead of the
more relevant `discarded section`.)
Note, glibc i386's crti.o still works (PR31215), because
`.gnu.linkonce.t.__x86.get_pc_thunk.bx` is in crti.o (one of the first
regular object files in a linker command line).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79300
Files:
lld/ELF/InputFiles.cpp
lld/test/ELF/comdat-discarded-lazy.s
lld/test/ELF/i386-linkonce.s
lld/test/ELF/start-lib-comdat.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79300.261677.patch
Type: text/x-patch
Size: 5808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200503/6115d015/attachment.bin>
More information about the llvm-commits
mailing list