Skip to content

Commit df46abe

Browse files
committed
[PAC] Enable support for FPTR_TYPE_DISCR in ABI Version
Also remove error messages/tests that used to guarded it.
1 parent 7708e94 commit df46abe

4 files changed

Lines changed: 5 additions & 38 deletions

File tree

compiler/rustc_session/src/diagnostics.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,6 @@ pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
381381
pub(crate) target_triple: &'a TargetTuple,
382382
}
383383

384-
#[derive(Diagnostic)]
385-
#[diag("function pointer type discrimination is not supported")]
386-
pub(crate) struct PointerAuthenticationTypeDiscriminationNotSupportedForTarget<'a> {
387-
pub(crate) target_triple: &'a TargetTuple,
388-
}
389-
390384
#[derive(Diagnostic)]
391385
#[diag(
392386
"`-Z pointer-authentication` is not supported for target {$target_triple} and will be ignored"

compiler/rustc_session/src/session.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ impl PointerAuthConfig {
209209
const GOT: u32 = 8;
210210
const GOTOS: u32 = 9;
211211
const TYPEINFO_VT_PTR_DISCR: u32 = 10;
212-
// FIXME(jchlanda) We don't yet support function pointer type discrimination.
213-
// const FPTR_TYPE_DISCR: u32 = 11;
212+
const FPTR_TYPE_DISCR: u32 = 11;
214213

215214
let pauth_abi_version: u32 = (u32::from(self.intrinsics) << INTRINSICS)
216215
| (u32::from(self.function_pointers.is_some()) << CALLS)
@@ -228,7 +227,10 @@ impl PointerAuthConfig {
228227
})) << INIT_FINI_ADDR_DISC)
229228
| (u32::from(self.elf_got) << GOT)
230229
| (u32::from(self.indirect_gotos) << GOTOS)
231-
| (u32::from(self.typeinfo_vt_ptr_discrimination) << TYPEINFO_VT_PTR_DISCR);
230+
| (u32::from(self.typeinfo_vt_ptr_discrimination) << TYPEINFO_VT_PTR_DISCR)
231+
| (u32::from(self.function_pointers.as_ref().is_some_and(|schema| {
232+
matches!(schema.discrimination_kind, PointerAuthDiscrimination::Type)
233+
})) << FPTR_TYPE_DISCR);
232234

233235
pauth_abi_version
234236
}
@@ -1446,19 +1448,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
14461448
sess.dcx().emit_err(diagnostics::LinkerPluginToWindowsNotSupported);
14471449
}
14481450

1449-
if sess
1450-
.pointer_auth_config
1451-
.as_ref()
1452-
.and_then(|cfg| cfg.function_pointers.as_ref())
1453-
.is_some_and(|schema| matches!(schema.discrimination_kind, PointerAuthDiscrimination::Type))
1454-
{
1455-
sess.dcx().emit_err(
1456-
diagnostics::PointerAuthenticationTypeDiscriminationNotSupportedForTarget {
1457-
target_triple: &sess.opts.target_triple,
1458-
},
1459-
);
1460-
}
1461-
14621451
if sess.target.cfg_abi != CfgAbi::Pauthtest
14631452
&& !sess.opts.unstable_opts.pointer_authentication.is_empty()
14641453
{

tests/ui/pointer_authentication/type_discrimination_not_supported_pointer_authentication.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/pointer_authentication/type_discrimination_not_supported_pointer_authentication.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)