This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Invalid program counters and unwinding
- From: Michael Matz <matz at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Jeff Law <law at redhat dot com>, Florian Weimer <fweimer at redhat dot com>, GCC <gcc at gcc dot gnu dot org>, GNU C Library <libc-alpha at sourceware dot org>, Binutils <binutils at sourceware dot org>, gnu-gabi at sourceware dot org
- Date: Mon, 2 Jul 2018 18:14:11 +0200 (CEST)
- Subject: Re: Invalid program counters and unwinding
- References: <ae764484-5bd4-5e40-ed50-81209eb54360@redhat.com> <6feeaf09-0bc2-238b-42df-2ff915f3581e@redhat.com> <2b47dbd9-f1a2-1bf0-06ca-fca40660fabf@redhat.com> <6c555c05-e6d7-f37a-577f-4e0559c36f76@redhat.com> <alpine.LSU.2.21.1807021743390.15410@wotan.suse.de> <20180702155448.GW7166@tucnak>
Hi,
On Mon, 2 Jul 2018, Jakub Jelinek wrote:
> > I disagree. ASM code often lacks unwind descriptors (now less than in
> > the past, but still). My rule of thumb is always: no descriptor ->
> > has to be a framepointer-using routine with standard calling sequence.
> > (I.e. declare the combination of no descriptor and no fp to be a bug).
> > Some of the callee-saved register will temporarily be wrong but
> > unwinding can continue.
>
> Doesn't that clash with the x86-64 ABI which says what kind of FDE use
> by default if none is found (essentially a standard leaf routine that
> doesn't change sp, nor save any registers)?
There is no such language in the psABI, no (at least I haven't found
anything; you had me worried for a moment :) ). But there's stronger one:
all functions through which unwinding is expected must provide CFI. So,
yes, such code isn't strictly conforming. But there we are, there's much
code that isn't and we still have to sensibly deal with it (if we can).
IMHO making guesses is better than to stop unwinding. And IMHO guessing
that it's FP-using is better than guessing that it's leaf, especially if
the PC in question was the result of a prior unwinding step (making it
clear that it certainly was _not_ leaf).
And then there are (toy?) compilers that don't emit CFI, but do use FPs
(totally psABI non-compliant, sure); IMHO we shouldn't pessimize them
unduly. Yeah, it's all a bit wonky, but why make it harder for those?
Ciao,
Michael.