-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KCFI: Use legal charset in shim encoding
To separate `ReifyReason::FnPtr` from `ReifyReason::VTable`, we hyphenated the shims. Hyphens are not actually legal, but underscores are, so use those instead.
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,30 @@ | ||
// Check KCFI extra mangling works correctly on v0 | ||
|
||
//@ needs-sanitizer-kcfi | ||
//@ no-prefer-dynamic | ||
//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 | ||
//@ build-pass | ||
|
||
trait Foo { | ||
fn foo(&self); | ||
} | ||
|
||
struct Bar; | ||
impl Foo for Bar { | ||
fn foo(&self) {} | ||
} | ||
|
||
struct Baz; | ||
impl Foo for Baz { | ||
#[track_caller] | ||
fn foo(&self) {} | ||
} | ||
|
||
fn main() { | ||
// Produces `ReifyShim(_, ReifyReason::FnPtr)` | ||
let f: fn(&Bar) = Bar::foo; | ||
f(&Bar); | ||
// Produces `ReifyShim(_, ReifyReason::Vtable)` | ||
let v: &dyn Foo = &Baz as _; | ||
v.foo(); | ||
} |