From patchwork Wed Jul 16 18:18:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 2094 Received: (qmail 22983 invoked by alias); 16 Jul 2014 18:18:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22956 invoked by uid 89); 16 Jul 2014 18:18:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_50, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Jul 2014 18:18:03 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 16 Jul 2014 11:18:01 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.64]) by fmsmga002.fm.intel.com with ESMTP; 16 Jul 2014 11:18:00 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id 1D54B200116; Wed, 16 Jul 2014 11:18:00 -0700 (PDT) Date: Wed, 16 Jul 2014 11:18:00 -0700 From: "H.J. Lu" To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: [PATCH] PR binutils/17154: Properly match PLT entry against .got.plt relocation Message-ID: <20140716181800.GA7834@intel.com> Reply-To: "H.J. Lu" References: <20140716180104.GA449@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140716180104.GA449@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) On Wed, Jul 16, 2014 at 11:01:04AM -0700, H.J. Lu wrote: > Relocations against .got.plt section may not be in the same order as > entries in PLT section. It is incorrect to assume that the Ith reloction > index against .got.plt section always maps to the (I + 1)th entry in PLT > section. This patch matches the .got.plt relocation offset/index in PLT > entry against the index in .got.plt relocation table. It only checks > R_*_JUMP_SLOT and R_*_IRELATIVE relocations. It ignores R_*_TLS_DESC > and R_*_TLSDESC relocations since they have different PLT entries. I > checked it into master. > > I checked in this patch to match PLT entry only for ELFOSABI_GNU input. H.J. --- * elf32-i386.c (elf_i386_plt_sym_val): Match PLT entry only for ELFOSABI_GNU input. * elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise. (elf_x86_64_plt_sym_val_offset_plt_bnd): Likewise. --- bfd/ChangeLog | 7 +++++++ bfd/elf32-i386.c | 4 ++++ bfd/elf64-x86-64.c | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5e9ce0f..9be9b8cf 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2014-07-16 H.J. Lu + * elf32-i386.c (elf_i386_plt_sym_val): Match PLT entry only for + ELFOSABI_GNU input. + * elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise. + (elf_x86_64_plt_sym_val_offset_plt_bnd): Likewise. + +2014-07-16 H.J. Lu + PR binutils/17154 * elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT and R_*_IRELATIVE relocation offset with PLT entry. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index aa01a7a..7c4b4bb 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -4994,6 +4994,10 @@ elf_i386_plt_sym_val (bfd_vma i, const asection *plt, const arelent *rel) abfd = plt->owner; bed = get_elf_i386_backend_data (abfd); plt_offset = bed->plt->plt_entry_size; + + if (elf_elfheader (abfd)->e_ident[EI_OSABI] != ELFOSABI_GNU) + return plt->vma + (i + 1) * plt_offset; + while (plt_offset < plt->size) { bfd_vma reloc_offset; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 5eea810..f71291e 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -5311,6 +5311,10 @@ elf_x86_64_plt_sym_val (bfd_vma i, const asection *plt, abfd = plt->owner; bed = get_elf_x86_64_backend_data (abfd); plt_offset = bed->plt_entry_size; + + if (elf_elfheader (abfd)->e_ident[EI_OSABI] != ELFOSABI_GNU) + return plt->vma + (i + 1) * plt_offset; + while (plt_offset < plt->size) { bfd_vma reloc_index; @@ -5340,6 +5344,10 @@ elf_x86_64_plt_sym_val_offset_plt_bnd (bfd_vma i, const asection *plt) const struct elf_x86_64_backend_data *bed = &elf_x86_64_bnd_arch_bed; bfd *abfd = plt->owner; bfd_vma plt_offset = bed->plt_entry_size; + + if (elf_elfheader (abfd)->e_ident[EI_OSABI] != ELFOSABI_GNU) + return i * sizeof (elf_x86_64_legacy_plt2_entry); + while (plt_offset < plt->size) { bfd_vma reloc_index;