From 3b162f73d8027dcd8261666a40e9bdfb40f4dacc Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Tue, 19 Nov 2024 10:20:15 +0300 Subject: [PAC][clang] Add signed GOT cc1 flag (#96160) Add `-fptrauth-elf-got` clang cc1 flag and set `ptrauth_elf_got` preprocessor feature and `PointerAuthELFGOT` LangOption correspondingly. No additional checks like ensuring OS binary format is ELF are performed: it should be done on clang driver level when a pauth-enabled environment implying signed GOT enabled is requested. If the cc1 flag is passed, "ptrauth-elf-got" IR module flag is set. --- clang/lib/CodeGen/CodeGenModule.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 508f534..4f45698 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1213,6 +1213,9 @@ void CodeGenModule::Release() { getModule().addModuleFlag(llvm::Module::Min, "sign-return-address-with-bkey", 1); + if (LangOpts.PointerAuthELFGOT) + getModule().addModuleFlag(llvm::Module::Min, "ptrauth-elf-got", 1); + if (getTriple().isOSLinux()) { assert(getTriple().isOSBinFormatELF()); using namespace llvm::ELF; -- cgit v1.1