[PATCH] sh: Fix args for __uClibc_main() in crt1.S

Takashi Yoshii yoshii.takashi at renesas.com
Wed Aug 6 07:05:34 UTC 2008


Hi,

As a comment in libc/sysdeps/linux/sh/crt1.S says
>	/* __uClibc_main (main, argc, argv, init, fini) */
, something wrong here. There should be two more args.

7th arg "stack_end" seems to be missing.
6th one is not listed, but the original code pushed register "r4" here.
It is not documented, but because ldso/ldso/sh/dl-startup.h explicitly sets
 0 to r4 just before jump here, there must be a kind of calling convention.
So, I preserve the code, and add a comment that this is the way to pass
rtld_fini from prior routine.
I really can't find any documents about this convention, though.

/yoshii

---
sh: Fix args for __uClibc_main() in crt1.S
  add missing 7th arg "stack_end".
  add comment of undocumented usage of r4.
  fix comment of expected __uClibc_main() prototype.

diff --git a/libc/sysdeps/linux/sh/crt1.S b/libc/sysdeps/linux/sh/crt1.S
--- a/libc/sysdeps/linux/sh/crt1.S
+++ b/libc/sysdeps/linux/sh/crt1.S
@@ -24,6 +24,11 @@
 
 	At this entry point, most registers' values are unspecified, except:
 
+   r4		Contains a function pointer to be registered with `atexit'.
+		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
    sp		The stack contains the arguments and environment:
    		0(sp)			argc
 		4(sp)			argv[0]
@@ -48,7 +53,8 @@ _start:
 	mov.l @r15+,r5
 	mov r15, r6
 
-	/* Push the fini func onto the stack */
+	/* Push the stack_end, rtld_fini and fini func onto the stack */
+	mov.l r6, at -r15
 	mov.l r4, at -r15
 	mov.l L_fini,r0
 	mov.l r0, at -r15
@@ -57,7 +63,7 @@ _start:
 	mov.l L_main,r4
 	mov.l L_init,r7
 
-	/* __uClibc_main (main, argc, argv, init, fini) */
+	/* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
 
 	/* Let the libc call main and exit with its return code.  */
 	mov.l L_uClibc_main,r1




More information about the uClibc mailing list