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"
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
