Issue |
136704
|
Summary |
lld default of --no-apply-dynamic-relocs is not ideal when no dynamic linking is required.
|
Labels |
lld
|
Assignees |
|
Reporter |
smithp35
|
The `--apply-dynamic-relocs` option controls whether the static linker should write the result of a RELA dynamic relocation into the place, when the relocation can be resolved statically.
lld defaults to `--no-apply-dynamic-relocs` whereas GNU ld defaults to `--apply-dynamic-relocs`
Normally it doesn't matter whether the dynamic relocations are resolved statically or not. However this can catch people out that have used `--pie`, and static linking. With `--apply-dynamic-relocs` the binary can be run at its static link time address without relocation, whereas with `--no-apply-dynamic-relocs` some relocations need to be resolved. We had an internal team that found their project trusted-firmware didn't work with clang/lld when linked with --pie but worked with gcc/ld.bfd. This was fixed by adding `--apply-dynamic-relocs` but that option isn't very discoverable.
This is a somewhat niche use-case, but there may be some tweaks we can make, either in lld or potentially the clang bare-metal driver to help out. Some thoughts:
* The bare metal driver could pass `--apply-dynamic-relocs` through to lld.
* LLD could switch to `--apply-dynamic-relocs` when static linking.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs