[PATCH v2 09/20] aarch64: Move saving user entry into _dl_start_user

Sergey Bugaev bugaevc@gmail.com
Sat Mar 23 17:32:50 GMT 2024


In the Hurd ports, _dl_start () does not return the normal way; instead,
_dl_sysdep_start () jumps to _dl_start_user directly using the RETURN_TO
macro.  Unlike in the i386 and x86_64 ports, the instruction that was
saving the returned user entry into a different register (to avoid it
getting clobbered by the _dl_init () call) was not marked as a part of
_dl_start_user, causing it to be skipped when jumping to _dl_start_user
using RETURN_TO, and control subsequently getting transferred to a
random address left in x21.

This should not make any difference for Linux ports, other than the
_dl_start_user label pointing to an earlier instruction.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 sysdeps/aarch64/dl-start.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/aarch64/dl-start.S b/sysdeps/aarch64/dl-start.S
index d645484e..e35431ca 100644
--- a/sysdeps/aarch64/dl-start.S
+++ b/sysdeps/aarch64/dl-start.S
@@ -29,10 +29,10 @@ ENTRY (_start)
 	PTR_ARG (0)
 	bl	_dl_start
 	/* Returns user entry point in x0.  */
-	mov	PTR_REG (21), PTR_REG (0)
 .globl _dl_start_user
 .type _dl_start_user, %function
 _dl_start_user:
+	mov	PTR_REG (21), PTR_REG (0)
 	/* Get argc.  */
 	ldr	PTR_REG (1), [sp]
 	/* Get argv.  */
-- 
2.44.0



More information about the Libc-alpha mailing list