[PATCH] lib/x86_64/setjmp: Use 32-bit zero idiom for shorter encoding

George Hu <[email protected]> Wed, 26 Nov 2025 12:55:57 +0800
Newsgroups org.gnu.grub-devel
Message-ID <[email protected]>
Switch from `xorq %rax, %rax` to `xorl %eax, %eax`. In 64-bit mode,
zeroing EAX implicitly clears RAX, and the 32-bit form encodes one
byte smaller while keeping identical semantics.

Signed-off-by: George Hu <[email protected]>
---
 grub-core/lib/x86_64/setjmp.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/lib/x86_64/setjmp.S b/grub-core/lib/x86_64/setjmp.S
index 6b151bc4d..4c6c81249 100644
--- a/grub-core/lib/x86_64/setjmp.S
+++ b/grub-core/lib/x86_64/setjmp.S
@@ -36,7 +36,7 @@ GRUB_MOD_LICENSE "GPLv3+"
  */
 FUNCTION(grub_setjmp)
 	pop	%rsi		/* Return address, and adjust the stack */
-	xorq	%rax, %rax
+	xorl	%eax, %eax
 	movq	%rbx, 0(%rdi)	/* RBX */
 	movq	%rsp, 8(%rdi)   /* RSP */
 	push	%rsi
-- 
2.52.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel