[PATCH] sh: Fix args for __uClibc_main() in crt1.S
Takashi Yoshii
yoshii.takashi at renesas.com
Thu Aug 7 08:28:12 UTC 2008
Thank you for your review.
I've found some of architectures other than SH set a pointer to _dl_fini()
to rtld_fini in ldso/ldso/*/dl-startup.h, which apparently SH should have, too.
I've add small patch. Though I am really not confidence of correctness....
This one set the pointer to _dl_init() after simple PC-relative relocation.
Test is as follows.
a.c:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static void msg(char *m){
int fd=open("/dev/tty",O_RDWR);
while(m && *m)
write(fd,m++,1);
}
#ifdef MAIN
main(){ msg("main\n"); }
#else
void initf(void) __attribute__ ((constructor));
void initf(void){ msg("init\n"); }
void finif(void) __attribute__ ((destructor));
void finif(void){ msg("fini\n"); }
#endif
$ gcc -fPIC -shared a.c -o a.so
$ gcc -DMAIN a.c -o a
$ LD_PRELOAD=./a.so ./a
init
main
fini
I even dont know if what rtld_fini do is this or not, though ;)
But, without fix, no "fini" line appears.
/yoshii
---
SH: dl-startup.h: Set pointer to _dl_fini as an arg to _start.
ldso/ldso/sh/dl-startup.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/ldso/ldso/sh/dl-startup.h b/ldso/ldso/sh/dl-startup.h
index 3e59093..398846c 100644
--- a/ldso/ldso/sh/dl-startup.h
+++ b/ldso/ldso/sh/dl-startup.h
@@ -12,10 +12,14 @@ __asm__(
" bsrf r0\n"
" add #4, r4\n"
".jmp_loc:\n"
+ " sts pr, r1 ! pr == here\n"
+ " mov.l .L_dl_fini, r4\n"
" jmp @r0\n"
- " mov #0, r4 !call _start with arg == 0\n"
+ " add r1, r4 !call _start with arg _dl_init\n"
".L_dl_start:\n"
" .long _dl_start-.jmp_loc\n"
+ ".L_dl_fini:\n"
+ " .long _dl_fini-.jmp_loc\n"
" .size _start,.-_start\n"
" .previous\n"
);
-- 1.5.4.5
More information about the uClibc
mailing list