Skip to content

Commit e72ac2a

Browse files
authored
Merge pull request #1790 from nbdd0121/master
Clarify interaction of asm-goto with IBT
2 parents ff6252f + eea601a commit e72ac2a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/inline-assembly.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ assert_eq!(y, [3, 2, 0, 1]);
371371
r[asm.operand-type.supported-operands.label]
372372
* `label <block>`
373373
- The address of the block is substituted into the asm template string. The assembly code may jump to the substituted address.
374+
- For targets that distinguish between direct jumps and indirect jumps (e.g. x86-64 with `cf-protection` enabled), the assembly code must not jump to the substituted address indirectly.
374375
- After execution of the block, the `asm!` expression returns.
375376
- The type of the block must be unit or `!` (never).
376377
- The block starts a new safety context; unsafe operations within the `label` block must be wrapped in an inner `unsafe` block, even though the entire `asm!` expression is already wrapped in `unsafe`.
@@ -1210,9 +1211,6 @@ unsafe { core::arch::asm!("", options(pure)); }
12101211
r[asm.options.checks.noreturn]
12111212
- It is a compile-time error to specify `noreturn` on an asm block with outputs and without labels.
12121213

1213-
r[asm.options.checks.label-with-outputs]
1214-
- It is a compile-time error to have any `label` blocks in an asm block with outputs.
1215-
12161214
```rust,compile_fail
12171215
# #[cfg(target_arch = "x86_64")] {
12181216
let z: i32;
@@ -1223,6 +1221,9 @@ unsafe { core::arch::asm!("mov {:e}, 1", out(reg) z, options(noreturn)); }
12231221
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
12241222
```
12251223

1224+
r[asm.options.checks.label-with-outputs]
1225+
- It is a compile-time error to have any `label` blocks in an asm block with outputs.
1226+
12261227
r[asm.options.naked_asm-restriction]
12271228
`naked_asm!` only supports the `att_syntax` and `raw` options. The remaining options are not meaningful because the inline assembly defines the whole function body.
12281229

0 commit comments

Comments
 (0)