diff --git a/src/arch/x86.rs b/src/arch/x86.rs index 16bc9ae..e1c4bb1 100644 --- a/src/arch/x86.rs +++ b/src/arch/x86.rs @@ -43,7 +43,8 @@ macro_rules! arch_static_key_init_nop_asm_template { }; } -// The `0x90,0x90,0x90` are three NOPs, which is to make sure the `jmp {0}` is at least 5 bytes long. +// Here we do not use `jmp {0}` because it may be compiled into a 3-byte jmp instead of 5 byte. +// See https://stackoverflow.com/q/74771372/10005095 #[doc(hidden)] #[macro_export] macro_rules! arch_static_key_init_jmp_asm_template { @@ -51,8 +52,8 @@ macro_rules! arch_static_key_init_jmp_asm_template { ::core::concat!( r#" 2: - jmp {0} - .byte 0x90,0x90,0x90 + .byte 0xe9 + .long ({0} - 4) - . .pushsection "#, $crate::os_static_key_sec_name_attr!(), r#" diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index 47e6966..c4ea629 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -43,7 +43,8 @@ macro_rules! arch_static_key_init_nop_asm_template { }; } -// The `0x90,0x90,0x90` are three NOPs, which is to make sure the `jmp {0}` is at least 5 bytes long. +// Here we do not use `jmp {0}` because it may be compiled into a 3-byte jmp instead of 5 byte. +// See https://stackoverflow.com/q/74771372/10005095 #[doc(hidden)] #[macro_export] macro_rules! arch_static_key_init_jmp_asm_template {