-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64][PAC][clang][ELF] Support PAuth ABI core info #85235
Changes from 4 commits
919af72
9924f57
f80f4bd
f069c9b
68bf805
f3abb48
6dcf86e
4fd37cf
2fd8f66
2038f8d
a33d91b
fdb26a1
87f2937
b0f9a19
9f6d65c
37a4d9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7203,6 +7203,33 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |
options::OPT_fno_ptrauth_intrinsics, false)) | ||
CmdArgs.push_back("-fptrauth-intrinsics"); | ||
|
||
if (Args.hasFlag(options::OPT_fptrauth_calls, options::OPT_fno_ptrauth_calls, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be added in Clang::AddAArch64TargetArgs and use addOptInFlag. See 6ff6191 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Fixed in 68bf805 |
||
false)) | ||
CmdArgs.push_back("-fptrauth-calls"); | ||
|
||
if (Args.hasFlag(options::OPT_fptrauth_returns, | ||
options::OPT_fno_ptrauth_returns, false)) | ||
CmdArgs.push_back("-fptrauth-returns"); | ||
|
||
if (Args.hasFlag(options::OPT_fptrauth_auth_traps, | ||
options::OPT_fno_ptrauth_auth_traps, false)) | ||
CmdArgs.push_back("-fptrauth-auth-traps"); | ||
|
||
if (Args.hasFlag( | ||
options::OPT_fptrauth_vtable_pointer_address_discrimination, | ||
options::OPT_fno_ptrauth_vtable_pointer_address_discrimination, | ||
false)) | ||
CmdArgs.push_back("-fptrauth-vtable-pointer-address-discrimination"); | ||
|
||
if (Args.hasFlag(options::OPT_fptrauth_vtable_pointer_type_discrimination, | ||
options::OPT_fno_ptrauth_vtable_pointer_type_discrimination, | ||
false)) | ||
CmdArgs.push_back("-fptrauth-vtable-pointer-type-discrimination"); | ||
|
||
if (Args.hasFlag(options::OPT_fptrauth_init_fini, | ||
options::OPT_fno_ptrauth_init_fini, false)) | ||
CmdArgs.push_back("-fptrauth-init-fini"); | ||
|
||
// -fsigned-bitfields is default, and clang doesn't yet support | ||
// -funsigned-bitfields. | ||
if (!Args.hasFlag(options::OPT_fsigned_bitfields, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// REQUIRES: aarch64-registered-target | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most clang/test/CodeGen tests don't need registered-target. You can check this by removing AArch64 from LLVM_TARGETS_TO_BUILD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensured that it's not needed and deleted in 2fd8f66, thanks |
||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thanks, see fdb26a1 |
||
// RUN: -fptrauth-intrinsics \ | ||
// RUN: -fptrauth-calls \ | ||
// RUN: -fptrauth-returns \ | ||
// RUN: -fptrauth-auth-traps \ | ||
// RUN: -fptrauth-vtable-pointer-address-discrimination \ | ||
// RUN: -fptrauth-vtable-pointer-type-discrimination \ | ||
// RUN: -fptrauth-init-fini %s | \ | ||
// RUN: FileCheck %s --check-prefix=ALL | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-intrinsics %s | FileCheck %s --check-prefix=INTRIN | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-calls %s | FileCheck %s --check-prefix=CALL | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-returns %s | FileCheck %s --check-prefix=RET | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-auth-traps %s | FileCheck %s --check-prefix=TRAP | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-calls -fptrauth-vtable-pointer-address-discrimination %s | \ | ||
// RUN: FileCheck %s --check-prefix=VPTRADDR | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-calls -fptrauth-vtable-pointer-type-discrimination %s | \ | ||
// RUN: FileCheck %s --check-prefix=VPTRTYPE | ||
|
||
// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ | ||
// RUN: -fptrauth-calls -fptrauth-init-fini %s | \ | ||
// RUN: FileCheck %s --check-prefix=INITFINI | ||
|
||
// ALL: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// ALL: !{i32 1, !"aarch64-elf-pauthabi-version", i32 127} | ||
|
||
// INTRIN: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// INTRIN: !{i32 1, !"aarch64-elf-pauthabi-version", i32 1} | ||
|
||
// CALL: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// CALL: !{i32 1, !"aarch64-elf-pauthabi-version", i32 2} | ||
|
||
// RET: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// RET: !{i32 1, !"aarch64-elf-pauthabi-version", i32 4} | ||
|
||
// TRAP: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// TRAP: !{i32 1, !"aarch64-elf-pauthabi-version", i32 8} | ||
|
||
// VPTRADDR: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// VPTRADDR: !{i32 1, !"aarch64-elf-pauthabi-version", i32 18} | ||
|
||
// VPTRTYPE: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// VPTRTYPE: !{i32 1, !"aarch64-elf-pauthabi-version", i32 34} | ||
|
||
// INITFINI: !{i32 1, !"aarch64-elf-pauthabi-platform", i32 268435458} | ||
// INITFINI: !{i32 1, !"aarch64-elf-pauthabi-version", i32 66} | ||
|
||
void foo() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Check that we can manually enable specific ptrauth features. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aarch64-ptrauth.c is more conventional for such target-specific features There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
// RUN: %clang --target=aarch64 -c %s -### 2>&1 | FileCheck %s --check-prefix NONE | ||
// NONE: "-cc1" | ||
// NONE-NOT: "-fptrauth-intrinsics" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thanks, see 4fd37cf |
||
// NONE-NOT: "-fptrauth-calls" | ||
// NONE-NOT: "-fptrauth-returns" | ||
// NONE-NOT: "-fptrauth-auth-traps" | ||
// NONE-NOT: "-fptrauth-vtable-pointer-address-discrimination" | ||
// NONE-NOT: "-fptrauth-vtable-pointer-type-discrimination" | ||
// NONE-NOT: "-fptrauth-init-fini" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-intrinsics -c %s -### 2>&1 | FileCheck %s --check-prefix INTRIN | ||
// INTRIN: "-cc1"{{.*}} "-fptrauth-intrinsics" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-calls -c %s -### 2>&1 | FileCheck %s --check-prefix CALL | ||
// CALL: "-cc1"{{.*}} "-fptrauth-calls" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-returns -c %s -### 2>&1 | FileCheck %s --check-prefix RETURN | ||
// RETURN: "-cc1"{{.*}} "-fptrauth-returns" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-auth-traps -c %s -### 2>&1 | FileCheck %s --check-prefix TRAPS | ||
// TRAPS: "-cc1"{{.*}} "-fptrauth-auth-traps" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-vtable-pointer-address-discrimination -c %s -### 2>&1 | FileCheck %s --check-prefix VPTR_ADDR_DISCR | ||
// VPTR_ADDR_DISCR: "-cc1"{{.*}} "-fptrauth-vtable-pointer-address-discrimination" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-vtable-pointer-type-discrimination -c %s -### 2>&1 | FileCheck %s --check-prefix VPTR_TYPE_DISCR | ||
// VPTR_TYPE_DISCR: "-cc1"{{.*}} "-fptrauth-vtable-pointer-type-discrimination" | ||
|
||
// RUN: %clang --target=aarch64 -fptrauth-init-fini -c %s -### 2>&1 | FileCheck %s --check-prefix INITFINI | ||
// INITFINI: "-cc1"{{.*}} "-fptrauth-init-fini" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux implies ELF. You can remove
getTriple().isOSBinFormatELF()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but I'll leave an assertion against ELF here. Theoretically, we might have non-ELF binary format on Linux, while the Linux itself seems to have deprecated COFF and a.out support and llvm does not seem to support them as well. This assertion makes sense to me since (a) it makes things clear that we want to check both Linux and ELF (b) this will notify us if in future we have binary formats other than ELF supported on Linux.
See 37a4d9d