This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][GIT PULL][v2.6.32] tracing/x86: Add check to detect GCC messing with mcount prologue
- From: "H. Peter Anvin" <hpa at zytor dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Jakub Jelinek <jakub at redhat dot com>, Thomas Gleixner <tglx at linutronix dot de>, "H.J. Lu" <hjl dot tools at gmail dot com>, rostedt at goodmis dot org, Ingo Molnar <mingo at elte dot hu>, LKML <linux-kernel at vger dot kernel dot org>, Andrew Morton <akpm at linux-foundation dot org>, Heiko Carstens <heiko dot carstens at de dot ibm dot com>, feng dot tang at intel dot com, Peter Zijlstra <peterz at infradead dot org>, Frederic Weisbecker <fweisbec at gmail dot com>, David Daney <ddaney at caviumnetworks dot com>, Richard Guenther <richard dot guenther at gmail dot com>, gcc <gcc at gcc dot gnu dot org>, Linus Torvalds <torvalds at linux-foundation dot org>
- Date: Tue, 24 Nov 2009 11:55:27 -0800
- Subject: Re: [PATCH][GIT PULL][v2.6.32] tracing/x86: Add check to detect GCC messing with mcount prologue
- References: <1258694593.22249.1012.camel@gandalf.stny.rr.com> <1258736456.22249.1032.camel@gandalf.stny.rr.com> <4B06EF6F.2050507@redhat.com> <6dc9ffc80911220138y15bfa91agccf5c29f1c30e09a@mail.gmail.com> <4B0972C9.302@redhat.com> <6dc9ffc80911221530t38d83cf6je739743c8d756667@mail.gmail.com> <4B0BF119.4070704@redhat.com> <alpine.LFD.2.00.0911241555170.24119@localhost.localdomain> <20091124150604.GJ22813@hs20-bc2-1.build.redhat.com> <4B0BFC84.7070806@redhat.com> <20091124153634.GK22813@hs20-bc2-1.build.redhat.com> <4B0BFFD0.2080203@redhat.com> <4B0C0C12.7040907@zytor.com> <4B0C13F4.5090106@redhat.com>
On 11/24/2009 09:12 AM, Andrew Haley wrote:
>>
>> If we're changing gcc anyway, then let's add the option of intercepting
>> the function at the point where the machine state is well-defined by
>> ABI, which is before the function stack frame is set up.
>
> Hmm. On the x86 I suppose we could just inject a naked call instruction,
> but not all aeches allow us to call anything before we've saved the return
> address. Or are you talking x86 only?
>
For x86, we should use a naked call.
For architectures where that is not possible, we should use a minimal
sequence such that the ABI state at the invocation point is 100% derivable.
On MIPS, for example, we could use a sequence such as:
mov at, ra
jal __fentry__
It would be up to __fentry__ to save the value in at and to restore it
back into ra before resuming, meaning that __fentry__ has a nonstandard
calling convention.
-hpa