[patch] x86_64: CFI unwinding stop in _start
Andreas Jaeger
aj@suse.com
Fri Mar 16 19:21:00 GMT 2012
On 03/16/2012 07:05 PM, Jan Kratochvil wrote:
> Hi,
>
> _start function has no valid unwinding, so it should be marked so.
>
> GDB backtrace of stripped executable now runs away as GDB sees neither main()
> nor _start (GDB sees the entry address but GDB does not see size of the
> function "_start" owning the entry address).
>
> $ echo 'main(){pause();}'|gcc -x c - -s; ./a.out& gdb -p $! -ex bt
> #0 0x00007fc4d92b70d0 in __pause_nocancel () at ../sysdeps/unix/syscall-template.S:82
> #1 0x00000000004004ea in ?? ()
> #2 0x00007fc4d921e735 in __libc_start_main (main=0x4004dc, ...) at libc-start.c:226
> #3 0x00000000004003f9 in ?? ()
> #4 0x00007fff46172278 in ?? ()
> #5 0x000000000000001c in ?? ()
> #6 0x0000000000000001 in ?? ()
> #7 0x00007fff46173e45 in ?? ()
> #8 0x0000000000000000 in ?? ()
> (gdb) q
> ->
> #0 0x00007f2ef69898f0 in __pause_nocancel () at ../sysdeps/unix/syscall-template.S:82
> #1 0x00000000004004ea in ?? ()
> #2 0x00007f2ef68f0735 in __libc_start_main (main=0x4004dc, ...) at libc-start.c:226
> #3 0x00000000004003f9 in ?? ()
> (gdb) q
>
> If ld.so called (and not jumped into) _start then _start could have valid
> unwind into ld.so. But until ld.so gets changed unwinding from _start cannot
> work anyway.
>
> I was asking for revert of such patch before but libgcc_s is fixed now so it
> should work:
> Re: [PATCH] Unwinding CFI stop at the outermost clone()
> http://sourceware.org/ml/libc-alpha/2006-12/msg00078.html
>
> Tested with glibc-2.15-28.fc17 it has no regressions in Fedora Koji x86_64 and
> no regressions with FSF GDB HEAD.
>
> For GDB it has FAIL->PASS there:
> -FAIL: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler.
> -FAIL: gdb.cp/gdb2495.exp: bt after returning from a popped frame
> +PASS: gdb.cp/gdb2495.exp: Call a function that raises an exception without a handler.
> +PASS: gdb.cp/gdb2495.exp: bt after returning from a popped frame
> But that was not intested. It is because GDB puts return breakpoint pad to
> _start now but that will be handled differently anyway - using stack space
> instead. Still even with the _start placement GDB expects exceptions unwinding
> stops there - which is a goal of this patch.
> [patch 1/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5
> http://sourceware.org/ml/gdb-patches/2012-03/msg00357.html
> [patch 2/2] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #5
> http://sourceware.org/ml/gdb-patches/2012-03/msg00358.html
>
thanks, this looks fine.
Shall I commit it for you (I assume you have no commit access)?
Andreas
> Thanks,
> Jan
>
>
> 2012-03-16 Jan Kratochvil<jan.kratochvil@redhat.com>
>
> * sysdeps/x86_64/elf/start.S: Include<sysdep.h>.
> (_start): Add cfi_startproc, cfi_undefined for rip and cfi_endproc.
>
> --- a/sysdeps/x86_64/elf/start.S
> +++ b/sysdeps/x86_64/elf/start.S
> @@ -53,12 +53,16 @@
> NULL
> */
>
> +#include<sysdep.h>
> #include "bp-sym.h"
>
> .text
> .globl _start
> .type _start,@function
> _start:
> + cfi_startproc;
> + /* Clearing frame pointer is insufficient, use CFI. */
> + cfi_undefined (rip);
> /* Clear the frame pointer. The ABI suggests this be done, to mark
> the outermost frame obviously. */
> xorl %ebp, %ebp
> @@ -113,6 +117,7 @@ _start:
> #endif
>
> hlt /* Crash if somehow `exit' does return. */
> + cfi_endproc;
>
> /* Define a symbol for the first piece of initialized data. */
> .data
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list