================ @@ -599,11 +599,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, const Driver &D = getToolChain().getDriver(); const llvm::Triple::ArchType Arch = TC.getArch(); const llvm::Triple &Triple = getToolChain().getEffectiveTriple(); + const bool IsStaticPIE = getStaticPIE(Args, TC); if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); CmdArgs.push_back("-Bstatic"); + if (IsStaticPIE) { + CmdArgs.push_back("-pie"); + CmdArgs.push_back("--no-dynamic-linker"); ---------------- quic-garvgupt wrote:
> think @petrhosek was asking specifically about the "--no-dynamic-linker" flag. Thanks for clarifying this. >I think for gnu ld it is necessary as it's possible to mix -static and -shared >according to the manpage. I presume this ensures that you get an error in that >case rather than a statically linked shared library. Yes, if it’s the default behavior for LLD, then it would still be necessary for GNU LD. When both `-static` and `-shared` are used i.e., when creating a statically linked shared library, all definitions within the library are fully resolved at link time and pulled from static libraries. In such cases, there is no need for a dynamic linker. https://github.com/llvm/llvm-project/pull/147589 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits