From b2691bb69e10ee363d42a3fc165247f330d25a67 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 22 Jul 2017 15:39:16 +0000 Subject: Prefer the definition of a variable in the executable over a definition in a shared library, even for commons. This is what the current generation of linkers (current bfd, gold, lld) do. This fixes the relocation R_X86_64_PC32 against `xxx' can not be used when making a shared object; recompile with -fPIC warnings that we have seen in ports with clang. This change is somewhat suspect as a similar change was reverted in upstream binutils at some point. However that was for another corner case on an architecture (s390) that we do not run on. Tested by naddy@, sthen@ --- gnu/usr.bin/binutils-2.17/bfd/elflink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gnu/usr.bin/binutils-2.17/bfd/elflink.c b/gnu/usr.bin/binutils-2.17/bfd/elflink.c index 2f1d604f1cb..a6d17dcb4d9 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elflink.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elflink.c @@ -1180,7 +1180,8 @@ _bfd_elf_merge_symbol (bfd *abfd, && (olddef || (h->root.type == bfd_link_hash_common && (newweak - || ELF_ST_TYPE (sym->st_info) == STT_FUNC)))) + || ELF_ST_TYPE (sym->st_info) == STT_FUNC + || (!olddyn && info->executable))))) { *override = TRUE; newdef = FALSE; -- cgit v1.2.3