Created attachment 9942 [details] reproduces behavior shown in report We discovered a change in behavior from Ubuntu 15.10 to Ubuntu 16.04. The difference appears to be the former has GNU ld (GNU Binutils for Ubuntu) 2.25.1 and the latter GNU ld (GNU Binutils for Ubuntu) 2.26.1 Attached is a stripped down example. With ld 2.25.1, we observe that the tentative definition of globalInt is resolved to the definition appearing in con.o (static) or libcon.so (shared). % ./app.static globalInt is 7 % LD_LIBRARY_PATH=. ./app.shared globalInt is 7 In ld 2.26.1, we observe that the tentative definition gets resolved the same way with the static link, but does not get resolved with the shared link the same way. Instead, the tentative definition is resolved to a new, secondary instance (in .bss rather than .data). % ./app.static globalInt is 7 % LD_LIBRARY_PATH=. ./app.shared globalInt is 0
This behaviour was introduced with git commit 07492f668d. https://sourceware.org/ml/binutils/2016-03/msg00082.html
Dup. *** This bug has been marked as a duplicate of bug 19579 ***
This isn't a dup. This bug is reporting a regression introduced by the fix for bug 19579.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8170f7693bc0a9442c0aa280197925db92d48ca6 commit 8170f7693bc0a9442c0aa280197925db92d48ca6 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Apr 7 07:40:14 2017 -0700 ELF: Check ELF_COMMON_DEF_P for common symbols Since common symbols that are turned into definitions don't have the DEF_REGULAR flag set, we need to check ELF_COMMON_DEF_P for common symbols. bfd/ PR ld/19579 PR ld/21306 * elf32-s390.c (elf_s390_finish_dynamic_symbol): Check ELF_COMMON_DEF_P for common symbols. * elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. * elflink.c (_bfd_elf_merge_symbol): Revert commits 202ac193bbbecc96a4978d1ac3d17148253f9b01 and 07492f668d2173da7a2bda3707ff0985e0f460b6. ld/ PR ld/19579 PR ld/21306 * testsuite/ld-elf/pr19579a.c (main): Updated.
The binutils-2_28-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5a0ac7ba3c5277b3ab04f55de23bccb7614a9e59 commit 5a0ac7ba3c5277b3ab04f55de23bccb7614a9e59 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Apr 7 07:40:14 2017 -0700 ELF: Check ELF_COMMON_DEF_P for common symbols Since common symbols that are turned into definitions don't have the DEF_REGULAR flag set, we need to check ELF_COMMON_DEF_P for common symbols. bfd/ PR ld/19579 PR ld/21306 * elf32-s390.c (elf_s390_finish_dynamic_symbol): Check ELF_COMMON_DEF_P for common symbols. * elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. * elflink.c (_bfd_elf_merge_symbol): Revert commits 202ac193bbbecc96a4978d1ac3d17148253f9b01 and 07492f668d2173da7a2bda3707ff0985e0f460b6. ld/ PR ld/19579 PR ld/21306 * testsuite/ld-elf/pr19579a.c (main): Updated. (cherry picked from commit 8170f7693bc0a9442c0aa280197925db92d48ca6)
Fixed for master and 2.28 branch.