From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90246 invoked by alias); 28 Apr 2017 14:29:49 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 90232 invoked by uid 89); 28 Apr 2017 14:29:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,NO_DNS_FOR_FROM,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga05.intel.com Received: from mga05.intel.com (HELO mga05.intel.com) (192.55.52.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Apr 2017 14:29:47 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 28 Apr 2017 07:29:47 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.218]) by fmsmga002.fm.intel.com with ESMTP; 28 Apr 2017 07:29:47 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id C35E42003B2; Fri, 28 Apr 2017 07:29:47 -0700 (PDT) Date: Fri, 28 Apr 2017 14:29:00 -0000 From: "H.J. Lu" To: binutils@sourceware.org Subject: [committed, PATCH] x86: Check plt_got before using .plt.got Message-ID: <20170428142947.GA7775@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-04/txt/msg00275.txt.bz2 Since the GOT procedure linkage table is supported only if plt_got isn't NULL, we need to check plt_got before using it. * elf32-i386.c (elf_i386_allocate_dynrelocs): Check plt_got before using .plt.got. * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-i386.c | 4 +++- bfd/elf64-x86-64.c | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3ae5c9f..75e1e38 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-04-28 H.J. Lu + + * elf32-i386.c (elf_i386_allocate_dynrelocs): Check plt_got + before using .plt.got. + * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise. + 2017-04-27 H.J. Lu * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Use "=" diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index c995ef5..e07a81f 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2727,7 +2727,9 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if PLT is used. */ eh->func_pointer_refcount = 0; - if ((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) + if (htab->plt_got != NULL + && (info->flags & DF_BIND_NOW) + && !h->pointer_equality_needed) { /* Don't use the regular PLT for DF_BIND_NOW. */ h->plt.offset = (bfd_vma) -1; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 6f9bc36..7c455f2 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3178,7 +3178,9 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) if PLT is used. */ eh->func_pointer_refcount = 0; - if ((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) + if (htab->plt_got != NULL + && (info->flags & DF_BIND_NOW) + && !h->pointer_equality_needed) { /* Don't use the regular PLT for DF_BIND_NOW. */ h->plt.offset = (bfd_vma) -1; -- 2.9.3