This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


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

GNU C Library master sources branch hjl/global created. glibc-2.16-ports-merge-743-g6b96893


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/global has been created
        at  6b96893cfb3aba8a614d8875926b6f7d4974a41f (commit)

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6b96893cfb3aba8a614d8875926b6f7d4974a41f

commit 6b96893cfb3aba8a614d8875926b6f7d4974a41f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Nov 21 07:06:15 2012 -0800

    Support DF_1_GLOBAL

diff --git a/elf/Makefile b/elf/Makefile
index 7e5c9c8..aa744e4 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -145,7 +145,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-audit1 tst-audit2 tst-audit8 \
 	 tst-stackguard1 tst-addr1 tst-thrlock \
 	 tst-unique1 tst-unique2 tst-unique3 tst-unique4 \
-	 tst-initorder tst-initorder2 tst-relsort1
+	 tst-initorder tst-initorder2 tst-relsort1 reldep10
 #	 reldep9
 test-srcs = tst-pathopt
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
@@ -745,6 +745,10 @@ $(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
 $(objpfx)reldep9: $(libdl)
 $(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
 
+LDFLAGS-reldep10 = -Wl,-z,global
+$(objpfx)reldep10: $(libdl)
+$(objpfx)reldep10.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
+
 $(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
 
 $(objpfx)tst-tls4: $(libdl)
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 9c39a34..2e3e7ec 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -240,6 +240,11 @@ dl_open_worker (void *a)
     /* This happens only if we load a DSO for 'sprof'.  */
     return;
 
+  /* Make the symbols defined in the object available for symbol resolution
+     of subsequently loaded objects if it is marked with DF_1_GLOBAL.  */
+  if (__builtin_expect (new->l_flags_1 & DF_1_GLOBAL, 0))
+    mode |= RTLD_GLOBAL;
+
   /* This object is directly loaded.  */
   ++new->l_direct_opencount;
 
diff --git a/elf/reldep10.c b/elf/reldep10.c
new file mode 100644
index 0000000..45ebcf9
--- /dev/null
+++ b/elf/reldep10.c
@@ -0,0 +1,101 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *h1;
+  void *h2;
+  int (*fp) (void);
+  int *vp;
+
+  mtrace ();
+
+  /* Open the two objects.  */
+  h1 = dlopen ("reldepmod1.so", RTLD_LAZY);
+  if (h1 == NULL)
+    {
+      printf ("cannot open reldepmod1.so: %s\n", dlerror ());
+      exit (1);
+    }
+  h2 = dlopen ("reldepmod3.so", RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      printf ("cannot open reldepmod3.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* Get the address of the variable in reldepmod1.so.  */
+  vp = dlsym (h1, "some_var");
+  if (vp == NULL)
+    {
+      printf ("cannot get address of \"some_var\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  *vp = 42;
+
+  /* Get the function `call_me' in the second object.  This has a
+     dependency which is resolved by a definition in reldepmod1.so.  */
+  fp = dlsym (h2, "call_me");
+  if (fp == NULL)
+    {
+      printf ("cannot get address of \"call_me\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* Call the function.  */
+  if (fp () != 0)
+    {
+      puts ("function \"call_me\" returned wrong result");
+      exit (1);
+    }
+
+  /* Now close the first object.  It must still be around since we have
+     an implicit dependency.  */
+  if (dlclose (h1) != 0)
+    {
+      printf ("closing h1 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* Open the first object again.   */
+  h1 = dlopen ("reldepmod1.so", RTLD_LAZY | RTLD_GLOBAL);
+  if (h1 == NULL)
+    {
+      printf ("cannot open reldepmod1.so the second time: %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* Get the variable address again.  */
+  vp = dlsym (h1, "some_var");
+  if (vp == NULL)
+    {
+      printf ("cannot get address of \"some_var\" the second time: %s\n",
+	      dlerror ());
+      exit (1);
+    }
+
+  /* The variable now must have its originial value.  */
+  if (*vp != 42)
+    {
+      puts ("variable \"some_var\" reset");
+      exit (1);
+    }
+
+  /* Close the first object again, we are done.  */
+  if (dlclose (h1) != 0)
+    {
+      printf ("closing h1 failed: %s\n", dlerror ());
+      exit (1);
+    }
+  if (dlclose (h2) != 0)
+    {
+      printf ("closing h2 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  return 0;
+}
diff --git a/include/elf.h b/include/elf.h
index 60658c6..d594bf5 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -7,6 +7,6 @@
 #  error DT_1_SUPPORTED_MASK is defined!
 # endif
 # define DT_1_SUPPORTED_MASK \
-   (DF_1_NOW | DF_1_NODELETE | DF_1_INITFIRST | DF_1_NOOPEN \
+   (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE | DF_1_INITFIRST | DF_1_NOOPEN \
     | DF_1_ORIGIN | DF_1_NODEFLIB)
 #endif

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


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