Hi Timo, unfortunately your fix isn't exactly correct.

2010/5/11 Timo Teräs <[email protected]>:
> GCC can emit prologue/epilogue code for the functions in various
> different cases:
>  - frame pointers
>  - PIC build (to load ebx for indirect calls/jumps)
>  - forced stack smashing protection
>
> If we used jump in such cases, we'd corrupt the call stack and
> crash.

Yes, but using call will push additional word on the stack
and the called function will use wrong offset to access
the parameter on stack.

> --- a/libm/ldouble_wrappers.c
> +++ b/libm/ldouble_wrappers.c
> @@ -60,7 +60,9 @@ long long func##l(long double x) \
>  * The return value is returned in st(0) per ABI in both cases (returning
>  * a long double or returning a double). So we can simply jump to func.
>  * Using __GI_func in jump to make optimized intra-library jump.
> - * gcc will still generate a useless "ret" after asm. Oh well...
> + *
> + * We do need to use call (instead of tail jump) as gcc can create
> + * stack frame, and push/modify/pop ebx during PIC build.
>  */
>  # define WRAPPER1(func) \
>  long double func##l(long double x) \
> @@ -69,7 +71,7 @@ long double func##l(long double x) \
>        __asm ( \
>        "       fldt    %1\n" \
>        "       fstpl   %1\n" \
> -       "       jmp     " __stringify(__GI_##func) "\n" \
> +       "       call    " __stringify(__GI_##func) "\n" \
>        : "=t" (st_top) \
>        : "m" (x) \
>        ); \


So instead of this, you need to update #if guard:

#if defined __i386__ && defined __OPTIMIZE__

Add more conditions so that it kicks in only when safe.

-- 
vda
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to