This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Fri, 21 Nov 2014 12:15:01 -0800
- Subject: Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- Authentication-results: sourceware.org; auth=none
- References: <20141118191113 dot GA2298 at intel dot com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Tue, Nov 18, 2014 at 11:11:13AM -0800, H.J. Lu wrote:
> Hi,
>
> I checked in this patch to check PC-relative offset overflow in pushq
> instruction in x86-64 PLT entry.
>
>
> H.J.
> --
> bfd/
>
> PR ld/17618
> * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
> PC-relative offset overflow in PLT entry.
>
I checked in this patch to optimize PC-relative offset overflow check.
H.J.
---
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a9e6787..1f5ad55 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-21 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Optimize
+ PC-relative offset overflow check.
+
2014-11-21 Alexander Cherepanov <cherepan@mccme.ru>
PR binutils/17512
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 432ab58..c64ff4f 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4749,8 +4749,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
bfd_byte *loc;
asection *plt, *gotplt, *relplt, *resolved_plt;
const struct elf_backend_data *bed;
- bfd_boolean gotplt_after_plt;
- int32_t plt_got_pcrel_offset;
+ bfd_vma plt_got_pcrel_offset;
/* When building a static executable, use .iplt, .igot.plt and
.rela.iplt sections for STT_GNU_IFUNC symbols. */
@@ -4864,10 +4863,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
- plt_got_insn_size);
/* Check PC-relative offset overflow in PLT entry. */
- gotplt_after_plt = (gotplt->output_section->vma
- > resolved_plt->output_section->vma);
- if ((gotplt_after_plt && plt_got_pcrel_offset < 0)
- || (!gotplt_after_plt && plt_got_pcrel_offset > 0))
+ if ((plt_got_pcrel_offset + 0x80000000) > 0xffffffff)
info->callbacks->einfo (_("%F%B: PC-relative offset overflow in PLT entry for `%s'\n"),
output_bfd, h->root.root.string);