svn commit: branches/uClibc-nptl: ldso/ldso/sh libc/sysdeps/linux/sh
carmelo at uclibc.org
carmelo at uclibc.org
Fri Aug 8 07:28:16 UTC 2008
Author: carmelo
Date: 2008-08-08 00:28:16 -0700 (Fri, 08 Aug 2008)
New Revision: 23070
Log:
Fix SH ldso sequence startup.
Pass via r4 the rtld finalizer
_dl_fini to the user application. This will be the 6^ arg of
__uClibc_main and will be registered with 'atexit'.
In this way the dynamic linker will be able to call destructors
defined within the loaded DSOs.
Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
Acked-by: Paul Mundt <lethal at linux-sh.org>
Add missing 7th arg "stack_end".
add comment of undocumented usage of r4.
fix comment of expected __uClibc_main() prototype.
Signed-off-by: Yoshii Takashi <yoshii.takashi at renesas.com>
Acked-by: Paul Mundt <lethal at linux-sh.org>
Modified:
branches/uClibc-nptl/ldso/ldso/sh/dl-startup.h
branches/uClibc-nptl/libc/sysdeps/linux/sh/crt1.S
Changeset:
Modified: branches/uClibc-nptl/ldso/ldso/sh/dl-startup.h
===================================================================
--- branches/uClibc-nptl/ldso/ldso/sh/dl-startup.h 2008-08-08 07:28:02 UTC (rev 23069)
+++ branches/uClibc-nptl/ldso/ldso/sh/dl-startup.h 2008-08-08 07:28:16 UTC (rev 23070)
@@ -12,10 +12,20 @@
" bsrf r0\n"
" add #4, r4\n"
".jmp_loc:\n"
- " jmp @r0\n"
- " mov #0, r4 !call _start with arg == 0\n"
+ " mov r0, r8 ! Save the user entry point address in r8\n"
+ " mov.l .L_got, r12 ! Load the GOT on r12\n"
+ " mova .L_got, r0\n"
+ " add r0, r12\n"
+ " mov.l .L_dl_fini, r0\n"
+ " mov.l @(r0,r12), r4 ! Pass the finalizer in r4\n"
+ " jmp @r8\n"
+ " nop\n"
".L_dl_start:\n"
" .long _dl_start-.jmp_loc\n"
+ ".L_dl_fini:\n"
+ " .long _dl_fini at GOT\n"
+ ".L_got:\n"
+ " .long _GLOBAL_OFFSET_TABLE_\n"
" .size _start,.-_start\n"
" .previous\n"
);
Modified: branches/uClibc-nptl/libc/sysdeps/linux/sh/crt1.S
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/sh/crt1.S 2008-08-08 07:28:02 UTC (rev 23069)
+++ branches/uClibc-nptl/libc/sysdeps/linux/sh/crt1.S 2008-08-08 07:28:16 UTC (rev 23070)
@@ -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 @@
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 @@
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-cvs
mailing list