From 1031c264fd23641111df1e12a35d0a8f7e82fb80 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 13 Feb 2018 14:31:53 -0800 Subject: [PATCH] x86: Properly check building shared library If a symbol is not defined in a regular file, and we are not generating a shared library, then set the symbol to its location in the .plt. This is required to make function pointers compare as equal between the normal executable and the shared library. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll, instead of bfd_link_pic, for building shared library. --- bfd/ChangeLog | 5 +++++ bfd/elfxx-x86.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 726225ac23f..77cdfe86bc8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2018-02-13 H.J. Lu + + * elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll, + instead of bfd_link_pic, for building shared library. + 2018-02-13 H.J. Lu PR gas/22791 diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index fc08d1b977f..bd36707fc03 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -200,7 +200,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) location in the .plt. This is required to make function pointers compare as equal between the normal executable and the shared library. */ - if (! bfd_link_pic (info) + if (! bfd_link_dll (info) && !h->def_regular) { if (use_plt_got) -- 2.30.2