[clang] Add necessary linker flags when -static-pie is enabled in BareMetal Toolchain (PR #147589)
Garvit Gupta via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 22 05:17:54 PDT 2025
quic-garvgupt wrote:
>One land-mine I've seen some people run into with LLD, is that it is --no-apply-dynamic-relocs by default. This means that if --pie is used then there must be a loader. However with --apply-dynamic-relocs no loader is needed if the program is run at its static link address.
https://sourceware.org/binutils/docs/ld/ARM.html#index-_002d_002dno_002dapply_002ddynamic_002drelocs
sadly in GNU ld that option is AArch64 only so it couldn't be universally applied.
I think with `-static-pie` the idea is to provide your own loader. Moreover, I think `--no-apply-dynamic-relocs` is consistent with `-static-pie` because `--apply-dynamic-relocs` will create a position-dependent binary, by default which will render usage of `*-pie` meaningless.
https://github.com/llvm/llvm-project/pull/147589
More information about the cfe-commits
mailing list