Implement ELF linker -z global option
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Nov 2012 22:16:05 +0000 (22:16 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Nov 2012 22:16:05 +0000 (22:16 +0000)
ld/

* ld.texinfo: Document "-z global".

* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Support
"-z global".
(gld${EMULATION_NAME}_list_options): Likewise.

ld/testsuite/

* ld-elf/global1.d: New file.

ld/ChangeLog
ld/emultempl/elf32.em
ld/ld.texinfo
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/global1.d [new file with mode: 0644]

index 4478030cc8d89150f8f58816c6e7196988cc34c4..7996b23f1f65ee531be7882c07ea2c2ab5cff7c7 100644 (file)
@@ -1,3 +1,11 @@
+2012-11-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld.texinfo: Document "-z global".
+
+       * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Support
+       "-z global".
+       (gld${EMULATION_NAME}_list_options): Likewise.
+
 2012-11-15  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        Port lib32 arrangement from Debian.
index 9e263a9e9f90d70822839e7614e363394c1d4340..acb01e5df1c5a70a10adc19009d57bea21c2a5a5 100644 (file)
@@ -2300,6 +2300,8 @@ fragment <<EOF
 EOF
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
 fragment <<EOF
+      else if (strcmp (optarg, "global") == 0)
+       link_info.flags_1 |= (bfd_vma) DF_1_GLOBAL;
       else if (strcmp (optarg, "initfirst") == 0)
        link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
       else if (strcmp (optarg, "interpose") == 0)
@@ -2419,6 +2421,9 @@ EOF
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
 fragment <<EOF
   fprintf (file, _("\
+  -z global                   Make symbols in DSO available for subsequently\n\
+                               loaded objects\n"));
+  fprintf (file, _("\
   -z initfirst                Mark DSO to be initialized first at runtime\n"));
   fprintf (file, _("\
   -z interpose                Mark object to interpose all DSOs but executable\n"));
index 4a8118ff873575c7a5c6b3832e49d1c5c733cef5..7670e96983f227078d02691860b439f0da4051ea 100644 (file)
@@ -1024,6 +1024,11 @@ shared libraries are still allowed.
 @item execstack
 Marks the object as requiring executable stack.
 
+@item global
+This option is only meaningful when building a shared object.  It makes
+the symbols defined by this shared object available for symbol resolution
+of subsequently loaded libraries.
+
 @item initfirst
 This option is only meaningful when building a shared object.
 It marks the object so that its runtime initialization will occur
index 0e7954849fdf649330fba3a7231f748338ddd9d6..81ec67cf033d5fe29c16873825c6834c1215d56d 100644 (file)
@@ -1,3 +1,7 @@
+2012-11-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld-elf/global1.d: New file.
+
 2012-11-07  James Murray   <jsm@jsm-net.demon.co.uk>
 
        * ld-m68hc11/movw.d: New test for 16bit relocate.
diff --git a/ld/testsuite/ld-elf/global1.d b/ld/testsuite/ld-elf/global1.d
new file mode 100644 (file)
index 0000000..eae7f0d
--- /dev/null
@@ -0,0 +1,8 @@
+#source: start.s
+#ld: -shared -z global
+#readelf: -d
+#target: *-*-linux* *-*-gnu*
+
+#...
+ 0x0*6ffffffb \(FLAGS_1\) *Flags: GLOBAL
+#pass