forked from OSchip/llvm-project
0557b1bdec
When parsing an object file, LLD interleaves undefined symbol resolution (which may recursively fetch other lazy objects) with defined symbol resolution. This may lead to surprising results, e.g. if an object file defines currently undefined symbols and references another lazy symbol, we may interleave defined symbols with the lazy fetch, potentially leading to the defined symbols resolving to different files. As an example, if both `a.a(a.o)` and `a.a(b.o)` define `foo` (not in COMDAT group, or in different COMDAT groups) and `__profd_foo` (in COMDAT group `__profd_foo`). LLD may resolve `foo` to `a.a(a.o)` and `__profd_foo` to `b.a(b.o)`, i.e. different files. ``` parse ArchiveFile a.a entry fetches a.a(a.o) parse ObjectFile a.o define entry define foo reference b b fetches a.a(b.o) parse ObjectFile b.o define prevailing __profd_foo define (ignored) non-prevailing __profd_foo ``` Assuming a set of interconnected symbols are defined all or none in several lazy objects. Arguably making them resolve to the same file is preferable than making them resolve to different files (some are lazy objects). The main argument favoring the new behavior is the stability. The relative order between a defined symbol and an undefined symbol does not change the symbol resolution behavior. Only the relative order between two undefined symbols can affect fetching behaviors. --- The real world case is reduced from a Fuchsia PGO usage: `a.a(a.o)` has a constructor within COMDAT group C5 while `a.a(b.o)` has a constructor within COMDAT group C2. Because they use different group signatures, they are not de-duplicated. It is not entirely whether Clang behavior is entirely conforming. LLD selects the PGO counter section (`__profd_*`) from `a.a(b.o)` and the constructor section from `a.a(a.o)`. The `__profd_*` is a SHF_LINK_ORDER section linking to its own non-prevailing constructor section, so LLD errors `sh_link points to discarded section`. This patch fixes the error. Differential Revision: https://reviews.llvm.org/D95985 |
||
---|---|---|
.. | ||
Arch | ||
AArch64ErrataFix.cpp | ||
AArch64ErrataFix.h | ||
ARMErrataFix.cpp | ||
ARMErrataFix.h | ||
CMakeLists.txt | ||
CallGraphSort.cpp | ||
CallGraphSort.h | ||
Config.h | ||
DWARF.cpp | ||
DWARF.h | ||
Driver.cpp | ||
Driver.h | ||
DriverUtils.cpp | ||
EhFrame.cpp | ||
EhFrame.h | ||
ICF.cpp | ||
ICF.h | ||
InputFiles.cpp | ||
InputFiles.h | ||
InputSection.cpp | ||
InputSection.h | ||
LTO.cpp | ||
LTO.h | ||
LinkerScript.cpp | ||
LinkerScript.h | ||
MapFile.cpp | ||
MapFile.h | ||
MarkLive.cpp | ||
MarkLive.h | ||
Options.td | ||
OutputSections.cpp | ||
OutputSections.h | ||
README.md | ||
Relocations.cpp | ||
Relocations.h | ||
ScriptLexer.cpp | ||
ScriptLexer.h | ||
ScriptParser.cpp | ||
ScriptParser.h | ||
SymbolTable.cpp | ||
SymbolTable.h | ||
Symbols.cpp | ||
Symbols.h | ||
SyntheticSections.cpp | ||
SyntheticSections.h | ||
Target.cpp | ||
Target.h | ||
Thunks.cpp | ||
Thunks.h | ||
Writer.cpp | ||
Writer.h |
README.md
See docs/NewLLD.rst