Update symbol version for symbol from linker script
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Feb 2016 23:13:35 +0000 (15:13 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Feb 2016 23:13:48 +0000 (15:13 -0800)
We need to update symbol version for symbols from linker script.

bfd/

PR ld/19698
* elflink.c (bfd_elf_record_link_assignment): Set versioned if
symbol version is unknown.

ld/

PR ld/19698
* testsuite/ld-elf/pr19698.d: New file.
* testsuite/ld-elf/pr19698.s: Likewise.
* testsuite/ld-elf/pr19698.t: Likewise.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-elf/pr19698.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr19698.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr19698.t [new file with mode: 0644]

index e48f76bdb5ce62c88ce9371dca31aa4719a363a1..2a32a6f0d9137cd6f9c5d5e017d9419d0040979e 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19698
+       * elflink.c (bfd_elf_record_link_assignment): Set versioned if
+       symbol version is unknown.
+
 2016-02-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_allocate_dynrelocs): Set plt_got.offset
index 7d565f5d152cd0c1efae831bcd169bedbb4f0732..993e9b91628385ed384394f89d46bcbe3867200d 100644 (file)
@@ -555,6 +555,19 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
   if (h == NULL)
     return provide;
 
+  if (h->versioned == unknown)
+    {
+      /* Set versioned if symbol version is unknown.  */
+      char *version = strrchr (name, ELF_VER_CHR);
+      if (version)
+       {
+         if (version > name && version[-1] != ELF_VER_CHR)
+           h->versioned = versioned_hidden;
+         else
+           h->versioned = versioned;
+       }
+    }
+
   switch (h->root.type)
     {
     case bfd_link_hash_defined:
index 7eacba8fe27f7c7ad02bd756fb4dabdd621df9a4..73d3f9d40986f45e1dc315b6fd0c992a4fcdbefa 100644 (file)
@@ -1,3 +1,10 @@
+2016-02-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19698
+       * testsuite/ld-elf/pr19698.d: New file.
+       * testsuite/ld-elf/pr19698.s: Likewise.
+       * testsuite/ld-elf/pr19698.t: Likewise.
+
 2016-02-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        * Makefile.am (ELF_X86_DEPS): New.
diff --git a/ld/testsuite/ld-elf/pr19698.d b/ld/testsuite/ld-elf/pr19698.d
new file mode 100644 (file)
index 0000000..a39f67a
--- /dev/null
@@ -0,0 +1,10 @@
+#ld: -shared $srcdir/$subdir/pr19698.t
+#readelf : --dyn-syms --wide
+#target: *-*-linux* *-*-gnu* *-*-solaris*
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +foo@VERS.1
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +foo@@VERS.2
+#pass
diff --git a/ld/testsuite/ld-elf/pr19698.s b/ld/testsuite/ld-elf/pr19698.s
new file mode 100644 (file)
index 0000000..875dca4
--- /dev/null
@@ -0,0 +1,5 @@
+       .text
+       .globl  foo
+       .type   foo, %function
+foo:
+       .byte 0
diff --git a/ld/testsuite/ld-elf/pr19698.t b/ld/testsuite/ld-elf/pr19698.t
new file mode 100644 (file)
index 0000000..09d9125
--- /dev/null
@@ -0,0 +1,11 @@
+"foo@VERS.1" = foo;
+
+VERSION {
+VERS.2 {
+  global:
+    foo;
+};
+
+VERS.1 {
+};
+}