From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24328 invoked by alias); 8 Jun 2004 13:11:40 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 24293 invoked from network); 8 Jun 2004 13:11:38 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sourceware.org with SMTP; 8 Jun 2004 13:11:38 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i58Ava3j014095; Tue, 8 Jun 2004 12:57:36 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i58AvZLY014093; Tue, 8 Jun 2004 12:57:35 +0200 Date: Tue, 08 Jun 2004 13:11:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix backtrace in statically linked programs on ia64/x86-64/s390{,x} Message-ID: <20040608105735.GE5191@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-06/txt/msg00006.txt.bz2 Hi! libgcc_s.so's unwinder has no way to get at the statically linked binary's unwind tables. For -static, we really want to use _Unwind_* stuff from libgcc_eh.a. 2004-06-08 Jakub Jelinek * sysdeps/s390/s390-32/backtrace.c (init): Guard with #ifdef SHARED. (unwind_backtrace, unwind_getip): Define #ifndef SHARED. (__backtrace): Don't call init #ifndef SHARED. * sysdeps/s390/s390-64/backtrace.c (init): Guard with #ifdef SHARED. (unwind_backtrace, unwind_getip): Define #ifndef SHARED. (__backtrace): Don't call init #ifndef SHARED. * sysdeps/ia64/backtrace.c (init): Guard with #ifdef SHARED. (unwind_backtrace, unwind_getip): Define #ifndef SHARED. (__backtrace): Don't call init #ifndef SHARED. --- libc/sysdeps/s390/s390-32/backtrace.c.jj 2003-12-11 22:23:20.000000000 +0100 +++ libc/sysdeps/s390/s390-32/backtrace.c 2004-06-08 14:56:56.516905061 +0200 @@ -1,5 +1,5 @@ /* Return backtrace of current program state. - Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -61,6 +61,7 @@ struct trace_arg int cnt, size; }; +#ifdef SHARED static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); @@ -77,6 +78,10 @@ init (void) if (unwind_getip == NULL) unwind_backtrace = NULL; } +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif static int __backchain_backtrace (void **array, int size) @@ -122,9 +127,11 @@ int __backtrace (void **array, int size) { struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; +#ifdef SHARED __libc_once_define (static, once); __libc_once (once, init); +#endif if (unwind_backtrace == NULL) return __backchain_backtrace (array, size); --- libc/sysdeps/s390/s390-64/backtrace.c.jj 2003-12-11 20:18:30.000000000 +0100 +++ libc/sysdeps/s390/s390-64/backtrace.c 2004-06-08 14:57:59.804563089 +0200 @@ -1,5 +1,5 @@ /* Return backtrace of current program state. 64 bit S/390 version. - Copyright (C) 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -60,6 +60,7 @@ struct trace_arg int cnt, size; }; +#ifdef SHARED static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); @@ -76,6 +77,10 @@ init (void) if (unwind_getip == NULL) unwind_backtrace = NULL; } +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif int __backchain_backtrace (void **array, int size) @@ -121,9 +126,11 @@ int __backtrace (void **array, int size) { struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; +#ifdef SHARED __libc_once_define (static, once); __libc_once (once, init); +#endif if (unwind_backtrace == NULL) return __backchain_backtrace (array, size); --- libc/sysdeps/ia64/backtrace.c.jj 2003-10-24 14:02:44.000000000 +0200 +++ libc/sysdeps/ia64/backtrace.c 2004-06-08 14:49:37.328613321 +0200 @@ -1,5 +1,5 @@ /* Return backtrace of current program state. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -30,6 +30,7 @@ struct trace_arg int cnt, size; }; +#ifdef SHARED static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); @@ -46,6 +47,10 @@ init (void) if (unwind_getip == NULL) unwind_backtrace = NULL; } +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a) @@ -67,11 +72,13 @@ __backtrace (array, size) int size; { struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; +#ifdef SHARED __libc_once_define (static, once); __libc_once (once, init); if (unwind_backtrace == NULL) return 0; +#endif if (size >= 1) unwind_backtrace (backtrace_helper, &arg); Jakub