-------- Original-Nachricht --------
> Datum: Fri, 11 Nov 2011 13:30:27 +0200
> Von: "Timo Teräs" <[email protected]>
> An: 
> CC: [email protected]
> Betreff: Re: [PATCH] libc/x86: fix stack unwinding and backtrace information

> On 11/10/2011 10:21 AM, Timo Teräs wrote:
> > When compiled without framepointer, the DWARF-2 CFI data is required
> > for proper stack unwinding.
> > 
> > This patch adds the CFI information to:
> >  * syscalls (so we get proper backtrace even for release builds)
> >  * new thread stub function (so the backtrace is clean for user
> >    created threads)
> > 
> > Also pads the signal return trampolines separate from other functions.
> > If CFI info was found for signal return code (which seems to happen if
> > it's located right next a valid function), it will not be recognized
> > as signal trampoline (gcc unwinder and gdb check first CFI info, and
> > only if it does not exists it compares the exact opcode sequence to
> > see if we are at signal return code block). This fixes a real crash
> > if thread is cancelled and the cancellation handler fails to detect the
> > signal return frame.
> > 
> > Signed-off-by: Timo Teräs <[email protected]>
> >
> > @@ -71,6 +72,8 @@ __asm__ (
> >     ".if 1 - \\name\n\t"    /* if reg!=ebx... */
> >     ".if 2 - \\name\n\t"    /* if reg can't be clobbered... */
> >     "pushl %ebx\n\t"        /* save ebx on stack */
> > +   CFI_ADJUST_CFA_OFFSET(4) "\n\t"
> > +   CFI_REL_OFFSET(ebx, 0) "\n\t"
> >     ".else\n\t"
> >     "xchgl \\reg, %ebx\n\t" /* else save ebx in reg, and load reg to ebx
> */
> >     ".endif\n\t"
> > @@ -89,6 +92,8 @@ __asm__ (
> >     ".if 1 - \\name\n\t"
> >     ".if 2 - \\name\n\t"    /* if reg can't be clobbered... */
> >     "popl %ebx\n\t"         /* restore ebx from stack */
> > +   CFI_ADJUST_CFA_OFFSET(-4) "\n\t"
> > +   CFI_RESTORE(ebx) "\n\t"
> >     ".else\n\t"
> >     "xchgl \\reg, %ebx\n\t" /* else restore ebx from reg */
> >     ".endif\n\t"
> 

IIRC the two if's are anyway a bit wrong (looked into it when I added DOMULTI 
config option), I wanted some time ago to convert these to the current usage in 
glibc (where for less arguments the content is only exchanged), the only 
stopper was how to implement _syscall6 for PIC code
I do not know how much the way of this implementation will influence the speed 
of execution, I can remember someone saying, that it is negligible. If so, the 
way the _syscall5 is done in glibc would be a way to implement _syscall6 as 
well.

Peter

> Actually, this bit does not work. The problems to be that the
> CFI_ADJUST_CFA_OFFSET() stuff emits assembler directives, which get
> interpreted regardless of the .if block we are at. Or something like
> that. In any case, some syscalls would not get the info right.
> 
> I'm now wondering if actually need the whole bpush/bpop/bmov hackery
> (even the comment suggests to remove it).
> For CFI generation, it'd be a lot better if we could just do push/pop of
> ebx always (for PIC builds) and leave it as-is for non-PIC builds.
> 
> I'll send a corrected patch doing that soon.
> _______________________________________________
> uClibc mailing list
> [email protected]
> http://lists.busybox.net/mailman/listinfo/uclibc

-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!               
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to