public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>
To: Denis Khalikov <d.khalikov@partner.samsung.com>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Cc: "v.barinov@samsung.com" <v.barinov@samsung.com>, nd <nd@arm.com>
Subject: Re: [PATCH] Frame pointer for arm with THUMB2 mode
Date: Wed, 05 Sep 2018 16:52:00 -0000	[thread overview]
Message-ID: <e61d4799-d4cf-3d57-1c39-93898d04c3d3@arm.com> (raw)
In-Reply-To: <20180905164347eucas1p110709b1cee4cac3f19bf8a900907d3de~Rjq5gLQGc2644226442eucas1p1O@eucas1p1.samsung.com>

On 05/09/18 17:43, Denis Khalikov wrote:
> Thanks for the answers.
> 
> I understood that, this hack makes more mess in codegen for arm,
> but can you please clarify what did you mean by
> 
>>Only a single register can be used
>> as the frame chain.
> 
> As far as I understood, GCC for arm with THUMB2 mode uses r7 register as
> frame pointer register by default (with -fno-omit-frame-pointer flag),
> GCC for arm with ARM mode uses r11, so I didn't really propose
> to change the frame pointer register.
> 

On entry to a function the code has to save the existing frame register.
 It doesn't know (can't trivially know) whether the caller is code
compiled in Arm state or Thumb state.  So how can it save the caller's
frame register if they are not the same?

Furthermore, the 'other' frame register (ie r7 in Arm state, r11 in
Thumb) is available as a call-saved register, so can contain any random
value.  If you try to use that random value during a frame chain walk
your program will most like take an access violation.  It will certainly
give you a garbage frame chain.

R.

> Thanks.
> 
> On 09/05/2018 06:32 PM, Wilco Dijkstra wrote:
>> Hi Denis,
>>
>>>> Adding support for a frame chain would require an ABI change. It
>>> would have to
>>>  > work across GCC, LLVM, Arm, Thumb-1 and Thumb-2 - not a trivial
>>> amount of
>>>  > effort.
>>
>>> Clang already works that way.
>>
>> No, that's incorrect like Richard pointed out. Only a single register
>> can be used
>> as the frame chain.
>>
>>> If we change the size of the traces to 2, it could be something like
>>> this:
>> ...
>>> At the first example we lost the full context, from where the
>>> control/data flow comes from.
>>
>> If 2 is not sufficient, then try 3 or 4. It may also be feasible to
>> only enable
>> deeper unwinding for particular libraries so you only pay an extra
>> cost for
>> leaks you are interested in.
>>
>>> The stack layout like this enables only with compile time flag
>>> (-mthumb-fp and works only together with -mthumb and
>>> -fno-omit-frame-pointer). It does not affect other codegen.
>>
>> But any code built like that will *always* run slower even if you
>> don't use
>> the sanitizer.
>>
>> Wilco
>>

  reply	other threads:[~2018-09-05 16:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180828004814epcas5p3fbd3af8edd93da263b6780ab3be11fe4@epcas5p3.samsung.com>
2018-08-28  0:48 ` Wilco Dijkstra
2018-08-28 10:44   ` Denis Khalikov
2018-09-05 12:11     ` Wilco Dijkstra
2018-09-05 13:53       ` Denis Khalikov
2018-09-05 13:56       ` Denis Khalikov
2018-09-05 14:11         ` Richard Earnshaw (lists)
2018-09-05 15:32         ` Wilco Dijkstra
2018-09-05 16:43           ` Denis Khalikov
2018-09-05 16:52             ` Richard Earnshaw (lists) [this message]
2018-09-05 17:01               ` Denis Khalikov
     [not found] <CGME20180827093530eucas1p2c931fb7d5bc0a73d2b657116b0288e1b@eucas1p2.samsung.com>
2018-08-27  9:35 ` Denis Khalikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e61d4799-d4cf-3d57-1c39-93898d04c3d3@arm.com \
    --to=richard.earnshaw@arm.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=d.khalikov@partner.samsung.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nd@arm.com \
    --cc=v.barinov@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).