other/8335: problems with __builtin_frame_address when -fomit-frame-pointer used

Davin McCall davmac@ozonline.com.au
Fri Oct 25 22:24:00 GMT 2002


(Resending with reduced attachments)

Hi,

>     Describe "doesn't work correctly".

By "doesn't work correctly" I mean:

__builtin_frame_address seems to expect that the frame address is stored in the %ebp register. However, if -fomit-frame-pointer is used, this is clearly not true.

In the attached files, see function "pthread_initialize". In particular in the generated assembly at ".L8:", which corresponds to the line referencing CURRENT_STACK_FRAME in the C source. CURRENT_STACK_FRAME is defined as "__builtin_frame_address(0)". In the assembly, I see "leal constant(%ebp),%edi" which is clearly wrong because it is using %ebp.

Incidentally, in other source compiled with -fomit-frame-pointer I remember seeing that %ebp was being used more-or-less as a general purpose register - so using it as the frame address could be wildly inaccurate.

>     The result should be the address of the stack frame, with or
>     without a frame pointer.  The frame is at a known offset from
>     the stack pointer, after all.

Well in that case I guess that this really is a bug.

best regards,
Davin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread.s
Type: application/octet-stream
Size: 30045 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20021025/ab3bd225/attachment.obj>


More information about the Gcc-bugs mailing list