diff options
| author | Daniel Kiss <daniel.kiss@arm.com> | 2022-04-13 09:31:25 +0200 |
|---|---|---|
| committer | Daniel Kiss <daniel.kiss@arm.com> | 2022-04-13 09:31:51 +0200 |
| commit | b0343a38a5910e980bb031e4014655d77cd0c162 (patch) | |
| tree | b2d4417f19ce2b5700b413d789ef23d7433c0fca /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | e5000624933e11e56a1530f1561efa136c9c8bd7 (diff) | |
Support the min of module flags when linking, use for AArch64 BTI/PAC-RET
LTO objects might compiled with different `mbranch-protection` flags which will cause an error in the linker.
Such a setup is allowed in the normal build with this change that is possible.
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D123493
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4efcc8447d81..b251a4a7df3d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -729,7 +729,10 @@ void CodeGenModule::Release() { // attributes, but we use module metadata to emit build attributes. This is // needed for LTO, where the function attributes are inside bitcode // serialised into a global variable by the time build attributes are - // emitted, so we can't access them. + // emitted, so we can't access them. LTO objects could be compiled with + // different flags therefore module flags are set to "Min" behavior to achieve + // the same end result of the normal build where e.g BTI is off if any object + // doesn't support it. if (Context.getTargetInfo().hasFeature("ptrauth") && LangOpts.getSignReturnAddressScope() != LangOptions::SignReturnAddressScopeKind::None) @@ -743,16 +746,16 @@ void CodeGenModule::Release() { Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_32 || Arch == llvm::Triple::aarch64_be) { - getModule().addModuleFlag(llvm::Module::Error, "branch-target-enforcement", + getModule().addModuleFlag(llvm::Module::Min, "branch-target-enforcement", LangOpts.BranchTargetEnforcement); - getModule().addModuleFlag(llvm::Module::Error, "sign-return-address", + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", LangOpts.hasSignReturnAddress()); - getModule().addModuleFlag(llvm::Module::Error, "sign-return-address-all", + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-all", LangOpts.isSignReturnAddressScopeAll()); - getModule().addModuleFlag(llvm::Module::Error, + getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-with-bkey", !LangOpts.isSignReturnAddressWithAKey()); } |
