aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-08-10 12:21:58 -0700
committerAndreas K. Hüttel <dilfridge@gentoo.org>2018-11-30 23:45:23 +0100
commit612de6a0d2b164816ee0d8ee8e8a2c7d3b2f477c (patch)
treeb759c2ea0b48dddbc52b509a6da727b30c6ec5b9
parentld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s (diff)
downloadbinutils-gdb-612de6a0d2b164816ee0d8ee8e8a2c7d3b2f477c.tar.gz
binutils-gdb-612de6a0d2b164816ee0d8ee8e8a2c7d3b2f477c.tar.bz2
binutils-gdb-612de6a0d2b164816ee0d8ee8e8a2c7d3b2f477c.zip
Always clear h->verinfo.verdef when overriding a dynamic definition
When linker defines a symbol to override a dynamic definition, it should always clear h->verinfo.verdef so that the symbol won't be associated with the version information from the dynamic object. This happened to the symbol "_edata" when creating an unversioned dynamic object linking against: 1. libKF5ConfigCore.so.5.49.0 2. libKF5CoreAddons.so.5.49.0 3. libKF5I18n.so.5.49.0 4. libKF5DBusAddons.so.5.49.0 5. libQt5Xml.so.5.11.1 6. libQt5DBus.so.5.11.1 7. libQt5Core.so.5.11.1 Among them libQt5Xml.so.5.11.1 299: 000000000003e000 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5 libQt5DBus.so.5.11.1 597: 0000000000092018 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5 libQt5Core.so.5.11.1 2292: 00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5 2293: 00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5 The problem is triggered by 2 duplicated entries of _edata@Qt_5 in libQt5Core.so.5.11.1 which was created by gold. Before this commit, ld created the dynamic object with "_edata" in its dynamic symbol table which was linker defined and associated with the version information from libQt5Core.so.5.11.1. The code in question was there when the binutils source was imported to sourceware.org. When such a dynamic object was used later, we got: /usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0) /usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value Tested with many ELF targets. PR ld/23499 * elflink.c (bfd_elf_record_link_assignment): Always clear h->verinfo.verdef when overriding a dynamic definition. (cherry picked from commit 48e30f5238c70e738f44474d595c476ef4e4ec38) (cherry picked from commit 76db6c1ac2cb4102e5551ab822afd84d88bb37aa) Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c12
2 files changed, 11 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7364bed2b53..f0eb899b264 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/23499
+ * elflink.c (bfd_elf_record_link_assignment): Always clear
+ h->verinfo.verdef when overriding a dynamic definition.
+
2018-08-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/23428
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 447af8f08c9..024ad271b08 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -686,13 +686,11 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
&& !h->def_regular)
h->root.type = bfd_link_hash_undefined;
- /* If this symbol is not being provided by the linker script, and it is
- currently defined by a dynamic object, but not by a regular object,
- then clear out any version information because the symbol will not be
- associated with the dynamic object any more. */
- if (!provide
- && h->def_dynamic
- && !h->def_regular)
+ /* If this symbol is currently defined by a dynamic object, but not
+ by a regular object, then clear out any version information because
+ the symbol will not be associated with the dynamic object any
+ more. */
+ if (h->def_dynamic && !h->def_regular)
h->verinfo.verdef = NULL;
/* Make sure this symbol is not garbage collected. */