Skip to content

[5.9] [AArch64][MachO] Support ptrauth ABI version. #7055

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

Merged

Conversation

ahmedbougacha
Copy link

This introduces additional meaning to some of the high bits in the mach-o header "flags" byte of the cpusubtype field. Quoting:

// arm64 reserves bits in the high byte for subtype-specific flags.
// On arm64e, the 6 low bits represent the ptrauth ABI version.
CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x3f000000,
// On arm64e, the top bit tells whether the Mach-O is versioned.
CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000,
// On arm64e, the 2nd high bit tells whether the Mach-O is using kernel ABI.
CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000

rdar://110506296
(cherry picked from commit 49328b6)

This introduces additional meaning to some of the high bits in the
mach-o header "flags" byte of the cpusubtype field.  Quoting:

  // arm64 reserves bits in the high byte for subtype-specific flags.
  // On arm64e, the 6 low bits represent the ptrauth ABI version.
  CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x3f000000,
  // On arm64e, the top bit tells whether the Mach-O is versioned.
  CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000,
  // On arm64e, the 2nd high bit tells whether the Mach-O is using kernel ABI.
  CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000

rdar://110506296
(cherry picked from commit 49328b6)
@ahmedbougacha
Copy link
Author

@swift-ci test

@fredriss fredriss merged commit 51283c4 into swift/release/5.9 Jul 10, 2023
@ahmedbougacha ahmedbougacha deleted the eng/abougacha/arm64e-ptrauth-abi-version-swift5.9 branch July 10, 2023 20:26
@@ -0,0 +1,16 @@
// Check the ABI version support.

// RUN: %clang -fptrauth-abi-version=5 -arch arm64e -c %s -### 2>&1 | FileCheck %s --check-prefix ABIVERSION --check-prefix NOKERNELABIVERSION

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmedbougacha This test and the defaults version above are failing on Linux:

warning: argument unused during compilation: '-fptrauth-abi-version=5' [-Wunused-command-line-argument]
warning: argument unused during compilation: '-arch arm64e' [-Wunused-command-line-argument]

The -arch flag seems to be Darwin specific: https://github.com/apple/llvm-project/blob/next/clang/docs/CommandGuide/clang.rst, and at a glance the new ptrauth ABI related flags are also only used on Darwin.

Can we gate these tests behind a REQUIRES: system-darwin or otherwise fix them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Removed -arch in favor of -target in:
#7071
#7072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants