Follow @Openwall on Twitter for new release announcements and other news
[<prev] [day] [month] [year] [list]
Message-Id: <20250907131250.2119965-1-tommi@hirvola.fi>
Date: Sun,  7 Sep 2025 16:12:50 +0300
From: Tommi Hirvola <tommi@...vola.fi>
To: musl@...ts.openwall.com
Cc: Tommi Hirvola <tommi@...vola.fi>
Subject: [PATCH] x86_64, x32: avoid useless REX.w in crt1.o _start

this shaves off 1 byte in crt1.o _start (x86_64, x32) by avoiding
useless REX prefix when clearing the rbp register to zero:

    48 31 ed | xor %rbp, %rbp
       31 ed | xor %ebp, %ebp

the semantics are identical as the latter "xor %ebp, %ebp" also resets
the upper 32 bits of %rbp to zero. however, "xor %ebp, %ebp" does not
require REX prefix (48) so its instruction encoding is one byte shorter.
hence, this commit switches from "xor %rbp, %rbp" to "xor %ebp, %ebp".
---
 arch/x32/crt_arch.h    | 2 +-
 arch/x86_64/crt_arch.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x32/crt_arch.h b/arch/x32/crt_arch.h
index b1c9c476..b7af4c4d 100644
--- a/arch/x32/crt_arch.h
+++ b/arch/x32/crt_arch.h
@@ -3,7 +3,7 @@ __asm__(
 ".global " START " \n"
 ".type " START ",%function \n"
 START ": \n"
-"	xor %rbp,%rbp \n"
+"	xor %ebp,%ebp \n"
 "	mov %rsp,%rdi \n"
 ".weak _DYNAMIC \n"
 ".hidden _DYNAMIC \n"
diff --git a/arch/x86_64/crt_arch.h b/arch/x86_64/crt_arch.h
index b1c9c476..b7af4c4d 100644
--- a/arch/x86_64/crt_arch.h
+++ b/arch/x86_64/crt_arch.h
@@ -3,7 +3,7 @@ __asm__(
 ".global " START " \n"
 ".type " START ",%function \n"
 START ": \n"
-"	xor %rbp,%rbp \n"
+"	xor %ebp,%ebp \n"
 "	mov %rsp,%rdi \n"
 ".weak _DYNAMIC \n"
 ".hidden _DYNAMIC \n"
-- 
2.51.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.