[PATCH] sh: Fix args for __uClibc_main() in crt1.S
Carmelo AMOROSO
carmelo.amoroso at st.com
Thu Aug 7 09:08:31 UTC 2008
Takashi Yoshii wrote:
> 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.
>
Yes, we need. please look at my previous reply, where I've a patch
to solve it in a different way.
> 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.
>
[SNIP]
>
> I even dont know if what rtld_fini do is this or not, though ;)
> But, without fix, no "fini" line appears.
Yes, it's rtld_fini doing this. This is the flow:
__uClibc_main -> main() -> exit -> __uClibc_fini() -> rtld_fini
>
> /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
Hum... I think that we are lucky because _dl_fini is defined in ldso.c
that includes dl-startup.c that includes dl-startup.h... but if _dl_fini
were defined in another compilation units ? does it work ? am I correct ?
My solution is based on a more generic solution using a GOT entry.
What is the best solution ? comments ?
Carmelo
More information about the uClibc
mailing list