File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/doc/unstable-book/src/compiler-flags Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,9 @@ 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
+ #! [feature(naked_functions)]
249
+
248
250
use std::arch::naked_asm;
249
251
use std::mem;
250
252
@@ -253,6 +255,7 @@ fn add_one(x: i32) -> i32 {
253
255
}
254
256
255
257
# [unsafe(naked)]
258
+ # #[cfg(target_arch = "x86_64")]
256
259
pub extern " C" fn add_two(x: i32) {
257
260
// x + 2 preceded by a landing pad/nop block
258
261
naked_asm! (
@@ -276,6 +279,7 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
276
279
f(arg) + f(arg)
277
280
}
278
281
282
+ # #[cfg(target_arch = "x86_64")]
279
283
fn main () {
280
284
let answer = do_twice(add_one, 5);
281
285
@@ -292,6 +296,7 @@ fn main() {
292
296
293
297
println! (" The next answer is: {}" , next_answer);
294
298
}
299
+ # #[cfg(not(target_arch = "x86_64"))] fn main() {}
295
300
` ` `
296
301
Fig. 1. Redirecting control flow using an indirect branch/call to an invalid
297
302
destination (i.e., within the body of the function).
You can’t perform that action at this time.
0 commit comments