Skip to content

Commit c651b66

Browse files
Auto merge of #139113 - folkertdev:sanitizer-unstable-book-check-block, r=<try>
unstable book: in a sanitizer example, check the code try-job: aarch64-apple
2 parents 1bc901e + 4524d9d commit c651b66

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/doc/unstable-book/src/compiler-flags/sanitizer.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ See the [Clang ControlFlowIntegrity documentation][clang-cfi] for more details.
244244
245245
## Example 1: Redirecting control flow using an indirect branch/call to an invalid destination
246246
247-
```rust,ignore (making doc tests pass cross-platform is hard)
247+
```rust
248248
use std::arch::naked_asm;
249249
use std::mem;
250250

@@ -253,6 +253,7 @@ fn add_one(x: i32) -> i32 {
253253
}
254254

255255
#[unsafe(naked)]
256+
# #[cfg(target_arch = "x86_64")]
256257
pub extern "C" fn add_two(x: i32) {
257258
// x + 2 preceded by a landing pad/nop block
258259
naked_asm!(
@@ -276,6 +277,7 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
276277
f(arg) + f(arg)
277278
}
278279

280+
# #[cfg(target_arch = "x86_64")]
279281
fn main() {
280282
let answer = do_twice(add_one, 5);
281283

@@ -292,6 +294,7 @@ fn main() {
292294

293295
println!("The next answer is: {}", next_answer);
294296
}
297+
# #[cfg(not(target_arch = "x86_64"))] fn main() {}
295298
```
296299
Fig. 1. Redirecting control flow using an indirect branch/call to an invalid
297300
destination (i.e., within the body of the function).

0 commit comments

Comments
 (0)