[PAC] Minicore updates to support fn ptr type discriminator tests (7/8)#159086
[PAC] Minicore updates to support fn ptr type discriminator tests (7/8)#159086jchlanda wants to merge 8 commits into
Conversation
54447d2 to
6c09f27
Compare
This comment has been minimized.
This comment has been minimized.
a762c6a to
71a56a5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
71a56a5 to
d4e180d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d4e180d to
efa84d7
Compare
This comment has been minimized.
This comment has been minimized.
f8bd7ba to
d3e6fb9
Compare
|
|
||
| #[lang = "c_void"] | ||
| #[repr(u8)] | ||
| #[allow(non_camel_case_types)] |
There was a problem hiding this comment.
Why do we need this change? I see c_void used in tests, but I'm not sure why these naming changes are required (the enum elements do not look directly used in tests anyway)
There was a problem hiding this comment.
Without it tidy would fail (and it is run as part of PR CI tests).
| 7 | ||
| } | ||
| } | ||
| impl Add for i32 { |
There was a problem hiding this comment.
I failed to find direct uses of Add trait or add function in tests. Could you please explain why we need this new implementation for i32 here?
There was a problem hiding this comment.
Because + operator is resolved to Add, so without the code above this will fail to compile for minicore:
extern "C" fn foo(x: i32) -> i32 {
x + 1
}6ed41f8 to
b4ef371
Compare
This comment has been minimized.
This comment has been minimized.
b4ef371 to
6559148
Compare
This patch implements Rust's equivalent of Clang's function pointer type discriminator computation used in pointer authentication. Compatibility with Clang is a primary goal. The discriminator produced for a given external "C" function type must match the value computed by Clang so that function pointers can be exchanged safely between Rust and C code while preserving pointer authentication semantics. The implementation mirrors Clang's behavior in `ASTContext::encodeTypeForFunctionPointerAuth`, ensuring that identical C-compatible function types produce identical discriminators. See: <https://clang.llvm.org/doxygen/ASTContext_8cpp.html#abb1375e068e807917527842d05cadea3>.
This patch introduces the following: * Extends `FnAbi` (`callconv`) with a `ptrauth_type_discriminator` field. This field is only used when emitting pointer authentication call bundles. It is stored in `FnAbi` because the call site is not guaranteed to have access to an `Instance`, so the discriminator cannot always be computed on demand. * Adds support for `llvm.ptrauth.resign`. This intrinsic will be used when support for semantic transmute is added. * Performs a minor API redesign as groundwork for allowing call sites to modify schemas in place.
Also remove error messages/tests that used to guarded it.
The codegen now walks the layout of static initializer types to find extern "C" function pointer fields, computes their type discriminators, and applies those discriminators when emitting authenticated function pointer relocations. Also make sure that type discrimination is never applied to init/fini entries.
Implement pointer authentication domain handling for function pointer transmutes. When function pointer type discrimination is enabled, transmuting between function pointer types with different authentication domains now re-signs the pointer using the appropriate discriminator.
…addr` call sites Fill in function pointer type discriminators logic across remaining `get_fn_addr` call sites and explicitly avoid applying it where discrimination is not meaningful. Some uses of `get_fn_addr` are intentionally left unsigned, including the EH personality function, entry wrappers, and compiler-generated Rust ABI shims.
6559148 to
c926f3d
Compare
|
Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb |
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? compiler |
This patch prepares minicore for function pointer type discriminator tests.
This is part 7 of a sequence of 8 PRs that together implement support for function pointer type discrimination:
Useful links:
pauthtestintroduction: Introduce aarch64-unknown-linux-pauthtest target #155722