Fix handling of AArch64 local GOT relocs.

Resolves: #1262091
This commit is contained in:
Nick Clifton 2015-09-14 12:25:31 +01:00
parent 01a3d73c50
commit b17da75798
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,70 @@
--- binutils-2.25.orig/bfd/elfnn-aarch64.c 2015-09-14 12:05:10.010398108 +0100
+++ binutils-2.25/bfd/elfnn-aarch64.c 2015-09-14 12:12:40.730934194 +0100
@@ -2199,9 +2199,11 @@ aarch64_type_of_stub (struct bfd_link_in
globals = elf_aarch64_hash_table (info);
via_plt_p = (globals->root.splt != NULL && hash != NULL
&& hash->root.plt.offset != (bfd_vma) - 1);
-
+ /* Make sure call to plt stub can fit into the branch range. */
if (via_plt_p)
- return stub_type;
+ destination = (globals->root.splt->output_section->vma
+ + globals->root.splt->output_offset
+ + hash->root.plt.offset);
/* Determine where the call point is. */
location = (input_sec->output_offset
@@ -4392,38 +4394,25 @@ elfNN_aarch64_final_link_relocate (reloc
/* If the call goes through a PLT entry, make sure to
check distance to the right destination address. */
if (via_plt_p)
- {
- value = (splt->output_section->vma
- + splt->output_offset + h->plt.offset);
- *unresolved_reloc_p = FALSE;
- }
+ value = (splt->output_section->vma
+ + splt->output_offset + h->plt.offset);
- /* If the target symbol is global and marked as a function the
- relocation applies a function call or a tail call. In this
- situation we can veneer out of range branches. The veneers
- use IP0 and IP1 hence cannot be used arbitrary out of range
- branches that occur within the body of a function. */
- if (h && h->type == STT_FUNC)
- {
- /* Check if a stub has to be inserted because the destination
- is too far away. */
- if (! aarch64_valid_branch_p (value, place))
- {
- /* The target is out of reach, so redirect the branch to
- the local stub for this function. */
- struct elf_aarch64_stub_hash_entry *stub_entry;
- stub_entry = elfNN_aarch64_get_stub_entry (input_section,
- sym_sec, h,
- rel, globals);
- if (stub_entry != NULL)
- value = (stub_entry->stub_offset
- + stub_entry->stub_sec->output_offset
- + stub_entry->stub_sec->output_section->vma);
- }
- }
+ /* Check if a stub has to be inserted because the destination
+ is too far away. */
+ struct elf_aarch64_stub_hash_entry *stub_entry = NULL;
+ if (! aarch64_valid_branch_p (value, place))
+ /* The target is out of reach, so redirect the branch to
+ the local stub for this function. */
+ stub_entry = elfNN_aarch64_get_stub_entry (input_section, sym_sec, h,
+ rel, globals);
+ if (stub_entry != NULL)
+ value = (stub_entry->stub_offset
+ + stub_entry->stub_sec->output_offset
+ + stub_entry->stub_sec->output_section->vma);
}
value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
signed_addend, weak_undef_p);
+ *unresolved_reloc_p = FALSE;
break;
case BFD_RELOC_AARCH64_16:

View File

@ -19,7 +19,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.25
Release: 13%{?dist}
Release: 14%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -59,6 +59,8 @@ Patch16: binutils-2.25-aarch64-fPIC-error.patch
# backport https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e9c1bdad269c0c3352eebcc9481ed65144001b0b
# Qt linked with gold crash on startup, BZ #1193044
Patch17: binutils-2.25.1-dynamic_list.patch
# Fix creating GOT entries for AArch64 binaries.
Patch18: binutils-2.25-aarch64-pr18668.patch
Provides: bundled(libiberty)
@ -187,6 +189,7 @@ using libelf instead of BFD.
%patch16 -p1 -b .aarch64-fpic~
%endif
%patch17 -p1 -b .dynamic_list~
%patch18 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -500,6 +503,9 @@ exit 0
%endif # %{isnative}
%changelog
* Mon Sep 14 2015 Nick Clifton <nickc@redhat.com> 2.25-14
- Fix handling of AArch64 local GOT relocs. (#1262091)
* Mon Aug 24 2015 Rex Dieter <rdieter@fedoraproject.org> 2.25-13
- Qt linked with gold crash on startup (#1193044)