This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Re: A patch for static executable and dlopen
- To: gafton@redhat.com (Cristian Gafton)
- Subject: Re: A patch for static executable and dlopen
- From: hjl@lucon.org (H.J. Lu)
- Date: Sat, 2 May 1998 16:50:59 -0700 (PDT)
- Cc: drepper@cygnus.com, libc-hacker@cygnus.com (GNU C Library)
>
> On Thu, 30 Apr 1998, H.J. Lu wrote:
>
> > This patch seems to fix the dlopen/dlclose from the static executable
> > bug.
>
> Is this patch needed for 2.0.7 ?
>
It is needed for both 2.1 and 2.0.7. Here is a new revised patch. I
think it is correct.
Thanks.
--
H.J. Lu (hjl@gnu.org)
---
Sat May 2 16:21:03 1998 H.J. Lu <hjl@gnu.org>
* elf/dl-open.c (_dl_open): Increment the open count if the
shared object is put at the first place on the global scope
list.
Don't put the shared object on the global scope list twice.
Index: dl-open.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/elf/dl-open.c,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 dl-open.c
--- dl-open.c 1998/04/04 16:27:09 1.1.1.9
+++ dl-open.c 1998/05/02 23:06:02
@@ -112,7 +112,14 @@
}
new->l_global = (mode & RTLD_GLOBAL) ? 1 : 0;
- if (new->l_global)
+
+ if (_dl_loaded == new)
+ /* We are put at the first place on the global scope list, one way
+ or the other. We may be used by other shared objects. We have to
+ make sure that it stays in memory for them. Increment the open
+ count. */
+ new->l_opencount++;
+ else if (new->l_global)
{
/* The symbols of the new object and its dependencies are to be
introduced into the global scope that will be used to resolve