This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Avoid unnecessary dlopen libgcc_s.so
- From: "H. J. Lu" <hjl at lucon dot org>
- To: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Wed, 2 Nov 2005 09:43:46 -0800
- Subject: PATCH: Avoid unnecessary dlopen libgcc_s.so
When an executabl is linked against libgcc_s.so, there is no need to
dlopen libgcc_s.so. This patch avoids unnecessary dlopen libgcc_s.so.
H.J.
---
2005-11-01 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/backtrace.c (_Unwind_Backtrace): New weak
extern.
(unwind_backtrace): Initialized to _Unwind_Backtrace.
(_Unwind_GetIP): New weak extern.
(unwind_getip): Initialized to _Unwind_GetIP.
(_Unwind_GetCFA): New weak extern.
(unwind_getcfa): Initialized to _Unwind_GetCFA.
(_Unwind_GetGR): New weak extern.
(unwind_getgr): Initialized to _Unwind_GetGR.
(init): Return if unwind_backtrace, unwind_getip, unwind_getcfa
and unwind_getgr aren't NULL.
* sysdeps/ia64/backtrace.c (_Unwind_Backtrace): New weak extern.
(unwind_backtrace): Initialized to _Unwind_Backtrace.
(_Unwind_GetIP): New weak extern.
(unwind_getip): Initialized to _Unwind_GetIP.
(init): Return if unwind_backtrace and unwind_getip aren't NULL.
--- sysdeps/i386/backtrace.c.bt 2004-10-25 09:28:09.000000000 -0700
+++ sysdeps/i386/backtrace.c 2005-10-31 09:42:18.000000000 -0800
@@ -32,14 +32,35 @@ struct trace_arg
};
#ifdef SHARED
-static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
-static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
-static _Unwind_Ptr (*unwind_getcfa) (struct _Unwind_Context *);
-static _Unwind_Ptr (*unwind_getgr) (struct _Unwind_Context *, int);
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *)
+ __attribute__ ((__weak__));
+static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *)
+ = _Unwind_Backtrace;
+
+extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *)
+ __attribute__ ((__weak__));
+static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *)
+ = _Unwind_GetIP;
+
+extern _Unwind_Ptr _Unwind_GetCFA (struct _Unwind_Context *)
+ __attribute__ ((__weak__));
+static _Unwind_Ptr (*unwind_getcfa) (struct _Unwind_Context *)
+ = _Unwind_GetCFA;
+
+extern _Unwind_Ptr _Unwind_GetGR (struct _Unwind_Context *, int)
+ __attribute__ ((__weak__));
+static _Unwind_Ptr (*unwind_getgr) (struct _Unwind_Context *, int)
+ = _Unwind_GetGR;
static void
init (void)
{
+ if (unwind_backtrace != NULL
+ && unwind_getip != NULL
+ && unwind_getcfa != NULL
+ && unwind_getgr != NULL)
+ return;
+
void *handle = __libc_dlopen ("libgcc_s.so.1");
if (handle == NULL)
--- sysdeps/ia64/backtrace.c.bt 2004-06-22 00:19:00.000000000 -0700
+++ sysdeps/ia64/backtrace.c 2005-10-31 09:32:59.000000000 -0800
@@ -31,12 +31,22 @@ struct trace_arg
};
#ifdef SHARED
-static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
-static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *)
+ __attribute__ ((__weak__));
+static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *)
+ = _Unwind_Backtrace;
+
+extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *)
+ __attribute__ ((__weak__));
+static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *)
+ = _Unwind_GetIP;
static void
init (void)
{
+ if (unwind_backtrace != NULL && unwind_getip != NULL)
+ return;
+
void *handle = __libc_dlopen ("libgcc_s.so.1");
if (handle == NULL)