From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] [ARM] minor opt in thumb_stack_frame_destroyed_p
Date: Fri, 15 Apr 2016 16:24:00 -0000 [thread overview]
Message-ID: <571115C3.8010500@redhat.com> (raw)
In-Reply-To: <1460730578-28723-1-git-send-email-yao.qi@linaro.org>
On 04/15/2016 03:29 PM, Yao Qi wrote:
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -3135,6 +3135,14 @@ thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
> if (!find_pc_partial_function (pc, NULL, &func_start, &func_end))
> return 0;
>
> + if (func_end - pc > 4 * 4)
> + {
> + /* There shouldn't be more than four instructions in epilogue.
> + If PC is still 16 bytes away from FUNC_END, it isn't in
> + epilogue. */
This assumes epilogue sequences are always at the end of the function.
I suspected this isn't a safe assumption, and I asked gcc folks.
The answer I got was that gcc can and does emit epilogues in the
middle of functions. Below's an example I was given, and the
corresponding x86-64 and ARM disassembly. Note the 'retq' / 'bx lr'
in the middle.
#include <stdlib.h>
void f (int x)
{
if (x == 0)
abort();
}
Compile with -O2.
x86-64:
0000000000000000 <f>:
0: 85 ff test %edi,%edi
2: 74 02 je 6 <f+0x6>
4: f3 c3 repz retq
6: 50 push %rax
7: e8 00 00 00 00 callq c <f+0xc>
ARM:
00000000 <f>:
0: b100 cbz r0, 4 <f+0x4>
2: 4770 bx lr
4: b508 push {r3, lr}
6: f7ff fffe bl 0 <abort>
a: bf00 nop
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-04-15 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 14:30 Yao Qi
2016-04-15 16:24 ` Pedro Alves [this message]
2016-04-18 7:53 ` Yao Qi
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=571115C3.8010500@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.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