aboutsummaryrefslogtreecommitdiff
path: root/gold/x86_64.cc
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-11-18 11:34:11 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-11-21 11:26:56 -0800
commit9d585188889de38c7191976051d9acdd8d57cbbf (patch)
tree026f45f0a5ba574df76a3fbcda0898e1f81c887d /gold/x86_64.cc
parentb2a919a82b1d131c20f9e9c21b8c4871e5622d75 (diff)
downloadgdb-9d585188889de38c7191976051d9acdd8d57cbbf.zip
gdb-9d585188889de38c7191976051d9acdd8d57cbbf.tar.gz
gdb-9d585188889de38c7191976051d9acdd8d57cbbf.tar.bz2
Check PC-relative offset overflow in PLT entry
PR gold/17619 * x86_64.cc (Output_data_plt_x86_64_standard<size>::do_fill_plt_entry): Check PC-relative offset overflow in PLT entry.
Diffstat (limited to 'gold/x86_64.cc')
-rw-r--r--gold/x86_64.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 1fb601d..4baa2bf 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -1516,11 +1516,16 @@ Output_data_plt_x86_64_standard<size>::do_fill_plt_entry(
unsigned int plt_offset,
unsigned int plt_index)
{
+ // Check PC-relative offset overflow in PLT entry.
+ uint64_t plt_got_pcrel_offset = (got_address + got_offset
+ - (plt_address + plt_offset + 6));
+ if (Bits<32>::has_overflow(plt_got_pcrel_offset))
+ gold_error(_("PC-relative offset overflow in PLT entry %d"),
+ plt_index + 1);
+
memcpy(pov, plt_entry, plt_entry_size);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
- (got_address + got_offset
- - (plt_address + plt_offset
- + 6)));
+ plt_got_pcrel_offset);
elfcpp::Swap_unaligned<32, false>::writeval(pov + 7, plt_index);
elfcpp::Swap<32, false>::writeval(pov + 12,