forked from OSchip/llvm-project
![]() 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 |
||
---|---|---|
.. | ||
COFF | ||
Common | ||
ELF | ||
MachO | ||
MinGW | ||
cmake/modules | ||
docs | ||
include/lld | ||
lib | ||
test | ||
tools/lld | ||
unittests | ||
utils | ||
wasm | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
CMakeLists.txt | ||
CODE_OWNERS.TXT | ||
LICENSE.TXT | ||
README.md |
README.md
LLVM Linker (lld)
This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.
lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.
Benchmarking
In order to make sure various developers can evaluate patches over the same tests, we create a collection of self contained programs.
It is hosted at https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz
The current sha256 is 10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f
.