This is the mail archive of the gcc-patches@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: [PATCH] Stack corruption in naked functions.


On Fri, May 23, 2008 at 9:18 PM, Mark Mitchell <mark@codesourcery.com> wrote:
> Richard Guenther wrote:
>
>> I merely wanted to raise the concern that user errors will be noticed as
>> ICEs
>> and not errors, which will lead to false bug-reports.  It would be nice if
>> we
>> can emit an error, even if we cannot make sure to not ICE afterwards -
>> that
>> will be a confused after errors, which is way better than an ICE with an
>> instruction to report a bug.
>
> How does this relate to Carlos' patch?
>
> Carlos' patch keeps the compiler itself from copying arguments in registers
> to the stack for naked functions.  That doesn't sound like papering over to
> me; it sounds like an essential fix.
>
> How does Honza's patch relate to this at all?  Even if doing some
> optimizations would eliminate the copies, etc., depending on the optimizers
> to avoid using the stack seems fragile.

I thought the failure mode is that with -O0 we allocate stack slots for
incoming parameters (why? to eventually spill them or are they passed
via the stack?) and also access them, even as in the testcases they are
not used.  But I guess in the "real" testcases the arguments are used?

So the question is what does fix this with -O1?  Why can't we leverage
this same mechanism with -O0?  That is, what happens if we just change
use_register_for_decl to finish returning DECL_REGISTER unconditional
on optimize?  Or just unconditional on optimize if this is a PARM_DECL?

I guess I'm just too much curious, so I don't want to block this patch just
because of my lack of understanding on this matter ;)

Richard.


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