From b1e705146a26f5b650360edf2ecf05fec1315c33 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 29 Oct 2023 16:08:16 +0000 Subject: [PATCH] Unconditionally handle int $$0x29 using a shim --- src/inline_asm.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 0517c609337b..b2e27399055e 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -45,6 +45,14 @@ pub(crate) fn codegen_inline_asm<'tcx>( ) { // FIXME add .eh_frame unwind info directives + // Used by panic_abort on Windows, but uses a syntax which only happens to work with + // asm!() by accident and breaks with the GNU assembler as well as global_asm!() for + // the LLVM backend. + if template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) { + fx.bcx.ins().trap(TrapCode::User(1)); + return; + } + if !asm_supported(fx.tcx) { if template.is_empty() { let destination_block = fx.get_block(destination.unwrap()); @@ -52,12 +60,6 @@ pub(crate) fn codegen_inline_asm<'tcx>( return; } - // Used by panic_abort - if template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) { - fx.bcx.ins().trap(TrapCode::User(1)); - return; - } - // Used by stdarch if template[0] == InlineAsmTemplatePiece::String("mov ".to_string()) && matches!(