File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
src/doc/unstable-book/src/compiler-flags Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,7 @@ See the [Clang ControlFlowIntegrity documentation][clang-cfi] for more details.
244
244
245
245
# # Example 1: Redirecting control flow using an indirect branch/call to an invalid destination
246
246
247
- ` ` ` rust,ignore (making doc tests pass cross-platform is hard)
247
+ ` ` ` rust
248
248
use std::arch::naked_asm;
249
249
use std::mem;
250
250
@@ -253,6 +253,7 @@ fn add_one(x: i32) -> i32 {
253
253
}
254
254
255
255
# [unsafe(naked)]
256
+ # #[cfg(target_arch = "x86_64")]
256
257
pub extern " C" fn add_two(x: i32) {
257
258
// x + 2 preceded by a landing pad/nop block
258
259
naked_asm! (
@@ -276,6 +277,7 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
276
277
f(arg) + f(arg)
277
278
}
278
279
280
+ # #[cfg(target_arch = "x86_64")]
279
281
fn main () {
280
282
let answer = do_twice(add_one, 5);
281
283
@@ -292,6 +294,7 @@ fn main() {
292
294
293
295
println! (" The next answer is: {}" , next_answer);
294
296
}
297
+ # #[cfg(not(target_arch = "x86_64"))] fn main() {}
295
298
` ` `
296
299
Fig. 1. Redirecting control flow using an indirect branch/call to an invalid
297
300
destination (i.e., within the body of the function).
You can’t perform that action at this time.
0 commit comments