This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix backtrace in statically linked programs on ia64/x86-64/s390{,x}


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  <jakub@redhat.com>

	* 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 <jakub@redhat.com>, 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]