Open Qubasa opened 3 years ago
For some reason, jmp segment:pointer
doesn't work in inline asm
ljmp segment, offset pointer
has to be used
@rustbot label: +A-inline-assembly +O-x86
Compile without errors because it is valid asm. The gas assembler can compile it without problems.
To be very pedantic, what valid ASM for the purposes of rustc looks like is dictated by LLVM, not the GNU (or any other, for that matter) toolchain. As LLVM postdates use of the real mode by a lot it is very plausible that its assembly parser(s) will be quite spotty in that respect.
Inline asm seems to be even more restrictive:
unsafe {
core::arch::asm!(
"
.code16
ljmp 0, offset 1f
1:
int3
.code64
",
options(noreturn)
)
}
seems to also be invalid syntax for inline asm with the same error (along with ljmp 0, 1f
and ljmp 0:1f
syntax).
I'm not sure of any way to work around this problem...
I tried this code:
A repo with minimal sample code: https://github.com/Luis-Hebendanz/rust_asm_error
I expected to see this happen: Compile without errors because it is valid asm. The gas assembler can compile it without problems.
Instead, this happened: It fails with an
error: unexpected token in argument list
Meta
rustc --version --verbose
:Backtrace
``` Compiling rust_err v0.1.0 (/home/lhebendanz/Projects/rust_err) error: unexpected token in argument list | note: instantiated into assembly here -->:33:12
|
33 | jmp 0x8:protected_mode_setup
| ^
error: aborting due to previous error
error: could not compile `rust_err`
To learn more, run the command again with --verbose.
```