Skip to content
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

[PAC][clang] Define ptrauth driver flags and preprocessor features #85232

Closed
wants to merge 1 commit into from

Conversation

kovdan01
Copy link
Contributor

Define the following clang driver flags:

  • -fptrauth-intrinsics: PointerAuthIntrinsics in LangOptions, ptrauth_intrinsics preprocessor feature;

  • -fptrauth-calls: PointerAuthCalls in LangOptions, ptrauth_calls and ptrauth_member_function_pointer_type_discrimination preprocessor features;

  • -fptrauth-returns: PointerAuthReturns in LangOptions, ptrauth_returns preprocessor feature;

  • -fptrauth-auth-traps: PointerAuthAuthTraps in LangOptions;

  • -fptrauth-vtable-pointer-address-discrimination: PointerAuthVTPtrAddressDiscrimination in LangOptions, ptrauth_vtable_pointer_address_discrimination preprocessor feature;

  • -fptrauth-vtable-pointer-type-discrimination: PointerAuthVTPtrTypeDiscrimination in LangOptions, ptrauth_vtable_pointer_type_discrimination preprocessor feature;

  • -fptrauth-init-fini: PointerAuthInitFini in LangOptions, ptrauth_init_fini preprocessor feature;

The patch only defines the flags and having corresponding LangOptions set does not affect codegen yet.

Co-authored-by: Ahmed Bougacha ahmed@bougacha.org

Copy link

github-actions bot commented Mar 14, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Define the following clang driver flags:

- `-fptrauth-intrinsics`: `PointerAuthIntrinsics` in `LangOptions`,
  `ptrauth_intrinsics` preprocessor feature;

- `-fptrauth-calls`: `PointerAuthCalls` in `LangOptions`, `ptrauth_calls` and
  `ptrauth_member_function_pointer_type_discrimination` preprocessor features;

- `-fptrauth-returns`: `PointerAuthReturns` in `LangOptions`,
  `ptrauth_returns` preprocessor feature;

- `-fptrauth-auth-traps`: `PointerAuthAuthTraps` in `LangOptions`;

- `-fptrauth-vtable-pointer-address-discrimination`:
  `PointerAuthVTPtrAddressDiscrimination` in `LangOptions`,
  `ptrauth_vtable_pointer_address_discrimination` preprocessor feature;

- `-fptrauth-vtable-pointer-type-discrimination`:
  `PointerAuthVTPtrTypeDiscrimination` in `LangOptions`,
  `ptrauth_vtable_pointer_type_discrimination` preprocessor feature;

- `-fptrauth-init-fini`: `PointerAuthInitFini` in `LangOptions`,
  `ptrauth_init_fini` preprocessor feature;

The patch only defines the flags and having corresponding `LangOptions`
set does not affect codegen yet.

Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
@kovdan01 kovdan01 force-pushed the pauth-clang-flags branch from d0138c7 to 1394471 Compare March 14, 2024 14:56
@kovdan01 kovdan01 requested a review from asl March 14, 2024 14:58
@kovdan01 kovdan01 closed this Mar 16, 2024
kovdan01 added a commit that referenced this pull request Apr 2, 2024
…RE_PAUTH` (#85231)

This adds support for `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` feature (as
defined in ARM-software/abi-aa#240) handling in
llvm-readobj and llvm-readelf. The following constants for supported
platforms are also introduced:

- `AARCH64_PAUTH_PLATFORM_INVALID = 0x0`
- `AARCH64_PAUTH_PLATFORM_BAREMETAL = 0x1`
- `AARCH64_PAUTH_PLATFORM_LLVM_LINUX = 0x10000002`

For the llvm_linux platform, output of the tools contains descriptions
of PAuth features which are enabled/disabled depending on the version
value. Version value bits correspond to the following `LangOptions`
defined in #85232:

- bit 0: `PointerAuthIntrinsics`;
- bit 1: `PointerAuthCalls`;
- bit 2: `PointerAuthReturns`;
- bit 3: `PointerAuthAuthTraps`;
- bit 4: `PointerAuthVTPtrAddressDiscrimination`;
- bit 5: `PointerAuthVTPtrTypeDiscrimination`;
- bit 6: `PointerAuthInitFini`.

Support for `.note.AARCH64-PAUTH-ABI-tag` is dropped since it's deleted
from the spec in ARM-software/abi-aa#250.
kovdan01 added a commit that referenced this pull request Apr 4, 2024
…RE_PAUTH` (#87545)

Reland #85231 after fixing build failure
https://lab.llvm.org/buildbot/#/builders/186/builds/15631.
Use `PRIx64` for format output of `uint64_t` as hex.
Original PR description below.

This adds support for `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` feature (as
defined in ARM-software/abi-aa#240) handling in
llvm-readobj and llvm-readelf. The following constants for supported
platforms are also introduced:

- `AARCH64_PAUTH_PLATFORM_INVALID = 0x0`
- `AARCH64_PAUTH_PLATFORM_BAREMETAL = 0x1`
- `AARCH64_PAUTH_PLATFORM_LLVM_LINUX = 0x10000002`

For the llvm_linux platform, output of the tools contains descriptions
of PAuth features which are enabled/disabled depending on the version
value. Version value bits correspond to the following `LangOptions`
defined in #85232:

- bit 0: `PointerAuthIntrinsics`;
- bit 1: `PointerAuthCalls`;
- bit 2: `PointerAuthReturns`;
- bit 3: `PointerAuthAuthTraps`;
- bit 4: `PointerAuthVTPtrAddressDiscrimination`;
- bit 5: `PointerAuthVTPtrTypeDiscrimination`;
- bit 6: `PointerAuthInitFini`.

Support for `.note.AARCH64-PAUTH-ABI-tag` is dropped since it's deleted
from the spec in ARM-software/abi-aa#250.
kovdan01 added a commit that referenced this pull request May 9, 2024
Depends on #87545

Emit PAuth ABI compatibility tag values as llvm module flags:
- `aarch64-elf-pauthabi-platform`
- `aarch64-elf-pauthabi-version`

For platform 0x10000002 (llvm_linux), the version value bits correspond
to the following LangOptions defined in #85232:

- bit 0: `PointerAuthIntrinsics`;
- bit 1: `PointerAuthCalls`;
- bit 2: `PointerAuthReturns`;
- bit 3: `PointerAuthAuthTraps`;
- bit 4: `PointerAuthVTPtrAddressDiscrimination`;
- bit 5: `PointerAuthVTPtrTypeDiscrimination`;
- bit 6: `PointerAuthInitFini`.

---------

Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
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.

1 participant