This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] gas: Improve documentation for cfi_remember/restore_state
- From: Alan Modra <amodra at gmail dot com>
- To: Martin Galvan <martin dot galvan at tallertechnologies dot com>
- Cc: binutils at sourceware dot org, nickc at redhat dot com
- Date: Mon, 18 Apr 2016 14:23:47 +0930
- Subject: Re: [PATCH] gas: Improve documentation for cfi_remember/restore_state
- Authentication-results: sourceware.org; auth=none
- References: <1460584160-17648-1-git-send-email-martin dot galvan at tallertechnologies dot com> <20160414063908 dot GE12302 at bubble dot grove dot modra dot org> <CAOKbPbZNwAJYOn0U5qmkWY0bGb873N1hduPZ0sCfc960zXwvJQ at mail dot gmail dot com> <20160414231603 dot GC27620 at bubble dot grove dot modra dot org> <CAOKbPbbsGbrQegMC9KE+m1eF9E0YBGOVR5tN0VDxws1thFovDQ at mail dot gmail dot com>
On Fri, Apr 15, 2016 at 11:21:31AM -0300, Martin Galvan wrote:
> On Thu, Apr 14, 2016 at 8:16 PM, Alan Modra <email@example.com> wrote:
> > On Thu, Apr 14, 2016 at 11:23:08AM -0300, Martin Galvan wrote:
> > > You mean something like:
> > >
> > > je label
> > > popq %rbx
> > > .cfi_remember_state
> > > .cfi_restore %rbx
> > > popq %rbp
> > > .cfi_restore %rbp
> > > popq %r12
> > > .cfi_restore %r12
> > > ret
> > >
> > > label:
> > > .cfi_restore_state
> > > /* Do something else */
> > >
> > > In that case we're using .cfi_restore_state to save us having to use
> > > multiple CFI directives to recreate the original save locations.
> > Yes, exactly. However the above example shows a gcc bug!
> If you're referring to the last example I sent (with the three pops),
> I wrote that manually. So it's a programmer bug, not gcc's :)
> > Hmm, seems like current mainline gcc is buggy in this area on x86_64.
> > I see this sort of thing around a tail call:
> > je .L4
> > popq %rbp
> > .cfi_remember_state
> > .cfi_def_cfa 7, 8
> > movl $1, %edi
> > jmp *%rax
> > .L4:
> > .cfi_restore_state
> > So the cfa is set back to rsp on popping rbp, but there ought to be a
> > ".cfi_restore 6". Otherwise when an async interrupt hits after the
> > pop of rbp, the unwinder will load rbp from the stack, which has just
> > been trashed by the interrupt handler..
> That's probably true, though. I can look into it a bit more if you
> want. I know next to nothing about gcc internals, but a couple guys at
> the office can give me a hand with it.
I suspect there's no need to look into it yourself. x86_64 doesn't
lack interested and capable developers.
> > It might be better to choose an example from gcc -fomit-frame-pointer
> > -fasynchronous-unwind-tables code.
> Could we keep my 3-pop example if I added the required CFA adjustment?
> I'd like to keep the example as simple as possible for the
Australia Development Lab, IBM