aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-11-16 16:03:40 -0800
committerH.J. Lu <hjl.tools@gmail.com>2012-11-16 16:03:40 -0800
commita09875396ef20fe972d4cd2e0685b3e369f5818f (patch)
treee7cf7c07eedceb872ad679d86704d8d3394a41c6
parent75852dbff5c314674c132b15b6db0206738046a8 (diff)
downloadbinutils-hjl/global.tar.gz
Implement linker -z global optionhjl/global
-rw-r--r--ld/ChangeLog.global7
-rw-r--r--ld/emultempl/elf32.em5
-rw-r--r--ld/ld.texinfo6
-rw-r--r--ld/testsuite/ChangeLog.global3
-rw-r--r--ld/testsuite/ld-elf/global1.d8
5 files changed, 29 insertions, 0 deletions
diff --git a/ld/ChangeLog.global b/ld/ChangeLog.global
new file mode 100644
index 000000000..4f054f49c
--- /dev/null
+++ b/ld/ChangeLog.global
@@ -0,0 +1,7 @@
+2012-11-16 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.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 9e263a9e9..acb01e5df 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -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"));
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 4a8118ff8..0e14343e4 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1024,6 +1024,12 @@ 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. It is supported by the GNU C library
+since version 2.17.
+
@item initfirst
This option is only meaningful when building a shared object.
It marks the object so that its runtime initialization will occur
diff --git a/ld/testsuite/ChangeLog.global b/ld/testsuite/ChangeLog.global
new file mode 100644
index 000000000..41bc1ad97
--- /dev/null
+++ b/ld/testsuite/ChangeLog.global
@@ -0,0 +1,3 @@
+2012-11-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/global1.d: New file.
diff --git a/ld/testsuite/ld-elf/global1.d b/ld/testsuite/ld-elf/global1.d
new file mode 100644
index 000000000..eae7f0d90
--- /dev/null
+++ b/ld/testsuite/ld-elf/global1.d
@@ -0,0 +1,8 @@
+#source: start.s
+#ld: -shared -z global
+#readelf: -d
+#target: *-*-linux* *-*-gnu*
+
+#...
+ 0x0*6ffffffb \(FLAGS_1\) *Flags: GLOBAL
+#pass