Skip to content

Commit e637dde

Browse files
committed
Mark all imported structs with pointer auth qualified field function ptrs as address only
1 parent 9dceb37 commit e637dde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ namespace {
22722272
// Classify the type according to its stored properties.
22732273
for (auto field : D->getStoredProperties()) {
22742274
auto pointerAuthQual = field->getPointerAuthQualifier();
2275-
if (pointerAuthQual && pointerAuthQual.isAddressDiscriminated()) {
2275+
if (pointerAuthQual.isPresent()) {
22762276
properties.setAddressOnly();
22772277
}
22782278
auto substFieldType =

test/SILGen/ptrauth_field_fptr_import.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ func test_field_fn_ptr_swap() {
4848
ptr_to_secure_struct!.pointee.secure_func_ptr2 = t
4949
}
5050

51+
// CHECK-LABEL: sil hidden [ossa] @$s25ptrauth_field_fptr_import05test_B12_fn_ptr_temps5Int32VyF :
52+
// CHECK: [[STK:%.*]] = alloc_stack $SecureStruct, let, name "struct_with_signed_val"
53+
// CHECK: [[FLD:%.*]] = struct_element_addr [[STK]] : $*SecureStruct, #SecureStruct.secure_func_ptr1
54+
// CHECK: [[SIGNED:%.*]] = begin_access [read] [signed] [[FLD]] : $*Optional<@convention(c) () -> Int32>
55+
// CHECK-LABEL: } // end sil function '$s25ptrauth_field_fptr_import05test_B12_fn_ptr_temps5Int32VyF'
56+
func test_field_fn_ptr_temp() -> Int32 {
57+
let struct_with_signed_val = ptr_to_secure_struct.pointee
58+
return struct_with_signed_val.secure_func_ptr1()
59+
}
60+
5161
// CHECK-LABEL: sil hidden [ossa] @$s25ptrauth_field_fptr_import024test_addr_discriminated_B8_fn_reads5Int32VyF :
5262
// CHECK: [[GLOB:%.*]] = global_addr @ptr_to_addr_discriminated_secure_struct : $*Optional<UnsafeMutablePointer<AddressDiscriminatedSecureStruct>>
5363
// CHECK: [[A1:%.*]] = begin_access [read] [dynamic] [[GLOB]] : $*Optional<UnsafeMutablePointer<AddressDiscriminatedSecureStruct>>

0 commit comments

Comments
 (0)