-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] Ensure pointers passed to runtime support functions are correctly signed #98276
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
ahmedbougacha
merged 7 commits into
llvm:main
from
swiftlang:eng/ojhunt/cxx-runtime-callback-function-ptrauth
Jul 17, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4b92c4a
Sign function pointers passed to atexit and __cxa_atexit.
rjmccall b00d0b2
Fix build and tests for upstream
ojhunt b0d4bda
[clang] Sign the dtor passed to __cxa_throw as a void(*)(void*) fptr.
ahmedbougacha d6e0101
Merge remote-tracking branch 'origin/llvm.org/main' into eng/ojhunt/c…
ojhunt f116be8
Update test to include test for type discriminated function pointers
ojhunt 4326a29
Merge remote-tracking branch 'origin/llvm.org/main' into eng/ojhunt/c…
ojhunt e9219d6
Address style comments
ojhunt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=CXAATEXIT | ||
|
||
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \ | ||
// RUN: -fno-use-cxa-atexit \ | ||
// RUN: | FileCheck %s --check-prefix=ATEXIT | ||
|
||
class Foo { | ||
public: | ||
~Foo() { | ||
} | ||
}; | ||
|
||
Foo global; | ||
|
||
// CXAATEXIT: define internal void @__cxx_global_var_init() | ||
// CXAATEXIT: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0), ptr @global, ptr @__dso_handle) | ||
|
||
|
||
// ATEXIT: define internal void @__cxx_global_var_init() | ||
// ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0)) | ||
|
||
// ATEXIT: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" { | ||
// ATEXIT: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK | ||
// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKDISC | ||
|
||
class Foo { | ||
public: | ||
~Foo() { | ||
} | ||
}; | ||
|
||
// CHECK-LABEL: define void @_Z1fv() | ||
// CHECK: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0)) | ||
|
||
// CHECKDISC-LABEL: define void @_Z1fv() | ||
// CHECKDISC: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942)) | ||
|
||
void f() { | ||
throw Foo(); | ||
} | ||
|
||
// __cxa_throw is defined to take its destructor as "void (*)(void *)" in the ABI. | ||
// CHECK-LABEL: define void @__cxa_throw({{.*}}) | ||
// CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 0) ] | ||
|
||
// CHECKDISC-LABEL: define void @__cxa_throw({{.*}}) | ||
// CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 10942) ] | ||
|
||
extern "C" void __cxa_throw(void *exception, void *, void (*dtor)(void *)) { | ||
dtor(exception); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.