This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


(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

Attachment: pthread.s
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]