[PATCH] libm/x86: use call instead of jump for wrappers

Timo Teräs timo.teras at iki.fi
Sun Oct 31 07:09:11 UTC 2010


On 10/31/2010 08:57 AM, Timo Teräs wrote:
> Alternatively we could write the wrappers to cope with PIC properly and
> use the GCC attribute naked. Or write the wrappers as .S file.

Or write the current assembly part correctly to use call:

>> @@ -69,7 +71,7 @@ long double func##l(long double x) \
>>        __asm ( \
>>        "       fldt    %1\n" \
>>        "       fstpl   %1\n" \

(Duh. Should have read this part to see that the floating point stuff is
written back to stack and not just modified in ST(0)).

So fix fstpl to push it proper position in stack.

>> -       "       jmp     " __stringify(__GI_##func) "\n" \
>> +       "       call    " __stringify(__GI_##func) "\n" \

And add the stack "pop" here.

>>        : "=t" (st_top) \
>>        : "m" (x) \
>>        ); \

Assembly tail jump in middle of the code simply makes too many
assumptions on how gcc works IMHO.

The assembly block can make gcc generate all kind of interesting things
depending on what the modifiers it has and what else the function is doing.

My suggestion is: never do that. If you want to do it, use pure
assembler function (in .S) then you control the full function. Otherwise
it's bound to break someone's build because GCC assumes that execution
returns to function after the assembly block.


More information about the uClibc mailing list