aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c24
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-elf/pr21389.map6
-rw-r--r--ld/testsuite/ld-elf/pr21389.s5
-rw-r--r--ld/testsuite/ld-elf/pr21389a.d10
-rw-r--r--ld/testsuite/ld-elf/pr21389b.d8
-rw-r--r--ld/testsuite/ld-elf/pr21389c.d8
8 files changed, 64 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b113a8b..f1ca8b4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21389
+ * elflink.c (bfd_elf_size_dynamic_sections): Get soname index
+ before generating the version definition section.
+
2017-04-17 Alan Modra <amodra@gmail.com>
* elflink.c (_bfd_elf_merge_symbol): Undo dynamic linking
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ec2032b..b93d4f3 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5948,14 +5948,11 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
struct bfd_link_info *info,
asection **sinterpptr)
{
- size_t soname_indx;
bfd *dynobj;
const struct elf_backend_data *bed;
*sinterpptr = NULL;
- soname_indx = (size_t) -1;
-
if (!is_elf_hash_table (info->hash))
return TRUE;
@@ -5970,6 +5967,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
struct elf_info_failed eif;
bfd_boolean all_defined;
asection *s;
+ size_t soname_indx;
eif.info = info;
eif.failed = FALSE;
@@ -5986,6 +5984,17 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
return FALSE;
}
+ if (soname != NULL)
+ {
+ soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
+ soname, TRUE);
+ if (soname_indx == (size_t) -1
+ || !_bfd_elf_add_dynamic_entry (info, DT_SONAME, soname_indx))
+ return FALSE;
+ }
+ else
+ soname_indx = (size_t) -1;
+
/* Make all global versions with definition. */
for (t = info->version_info; t != NULL; t = t->next)
for (d = t->globals.list; d != NULL; d = d->next)
@@ -6494,15 +6503,6 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
*sinterpptr = bfd_get_linker_section (dynobj, ".interp");
BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info) || info->nointerp);
- if (soname != NULL)
- {
- soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
- soname, TRUE);
- if (soname_indx == (size_t) -1
- || !_bfd_elf_add_dynamic_entry (info, DT_SONAME, soname_indx))
- return FALSE;
- }
-
if (info->symbolic)
{
if (!_bfd_elf_add_dynamic_entry (info, DT_SYMBOLIC, 0))
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 793847d..a5732a5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-04-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21389
+ * testsuite/ld-elf/pr21389.map: New file.
+ * testsuite/ld-elf/pr21389.s: Likewise.
+ * testsuite/ld-elf/pr21389a.d: Likewise.
+ * testsuite/ld-elf/pr21389b.d: Likewise.
+ * testsuite/ld-elf/pr21389c.d: Likewise.
+
2017-04-17 Alan Modra <amodra@gmail.com>
* testsuite/ld-elf/indirect5a.c,
diff --git a/ld/testsuite/ld-elf/pr21389.map b/ld/testsuite/ld-elf/pr21389.map
new file mode 100644
index 0000000..88c8c28
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21389.map
@@ -0,0 +1,6 @@
+FOO {
+global:
+ foo;
+local:
+ *;
+};
diff --git a/ld/testsuite/ld-elf/pr21389.s b/ld/testsuite/ld-elf/pr21389.s
new file mode 100644
index 0000000..a943cc6
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21389.s
@@ -0,0 +1,5 @@
+ .globl foo
+ .type foo,%object
+ .data
+foo:
+ .long 0
diff --git a/ld/testsuite/ld-elf/pr21389a.d b/ld/testsuite/ld-elf/pr21389a.d
new file mode 100644
index 0000000..2dcd175
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21389a.d
@@ -0,0 +1,10 @@
+#source: pr21389.s
+#ld: -shared --version-script pr21389.map -soname=pr21389.so
+#objdump: -p
+#target: *-*-linux* *-*-gnu*
+
+#...
+Version definitions:
+1 0x01 0x[0-9a-f]* pr21389.so
+2 0x00 0x[0-9a-f]* FOO
+#pass
diff --git a/ld/testsuite/ld-elf/pr21389b.d b/ld/testsuite/ld-elf/pr21389b.d
new file mode 100644
index 0000000..8dbc34b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21389b.d
@@ -0,0 +1,8 @@
+#source: pr21389.s
+#ld: -shared --version-script pr21389.map -soname=pr21389.so
+#readelf: -d
+#target: *-*-linux* *-*-gnu*
+
+#...
+ 0x[0-9a-f]* \(SONAME\) +Library soname: \[pr21389.so\]
+#pass
diff --git a/ld/testsuite/ld-elf/pr21389c.d b/ld/testsuite/ld-elf/pr21389c.d
new file mode 100644
index 0000000..76ac37b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21389c.d
@@ -0,0 +1,8 @@
+#source: pr21389.s
+#ld: -shared -soname=pr21389.so
+#readelf: -d
+#target: *-*-linux* *-*-gnu*
+
+#...
+ 0x[0-9a-f]* \(SONAME\) +Library soname: \[pr21389.so\]
+#pass