summaryrefslogtreecommitdiffstats
path: root/binutils-2.25
diff options
context:
space:
mode:
authorHan Shen <shenhan@google.com>2016-01-14 14:26:29 -0800
committerHan Shen <shenhan@google.com>2016-01-14 17:09:13 -0800
commit6579e31a8757a1df50ca408dd1b3cd3fe59bb4b6 (patch)
tree3747b2de9900c9278020f903fceaecc1186e5d55 /binutils-2.25
parenta95c2e5c5e5338f535c730b2333e797adf2872c0 (diff)
downloadtoolchain_binutils-6579e31a8757a1df50ca408dd1b3cd3fe59bb4b6.tar.gz
toolchain_binutils-6579e31a8757a1df50ca408dd1b3cd3fe59bb4b6.tar.bz2
toolchain_binutils-6579e31a8757a1df50ca408dd1b3cd3fe59bb4b6.zip
Backport trunk patch for not applying dynamic relocs.
Note, there is a small change from the origin patch - while in the upstream patch, the option --no-apply-dynamic is default off, it is on by default in this CL. This should not bring any changes to android or chromeos, because the relocation value this CL changes is not used by chromeos, and is not used by android either (after the fix in bionic months ago). The backported patch is - commit 0eccf19f96d6218dd7c2f8d13f0546c2b942cc08 Author: Cary Coutant <ccoutant@gmail.com> Date: Thu Nov 5 12:24:14 2015 -0800 Add aarch64-specific --no-apply-dynamic-relocs option. With --no-apply-dynamic-relocs on aarch64 targets, gold will not apply link-time values for absolute relocations that become dynamic relocations. This provides a workaround for broken Android dynamic linkers that use the link-time value as an extra addend to the relocation. gold/ PR gold/19163 * aarch64.cc (Target_aarch64::Relocate::relocate): Don't apply certain relocations if --no-apply-dynamic-relocs is set. * options.h (--apply-dynamic-relocs): New aarch64-specific option. Tested - build whole toolchain and built android N9 image. Change-Id: Ida524bbee2a83574cd9e78ffdad9270787327c78
Diffstat (limited to 'binutils-2.25')
-rw-r--r--binutils-2.25/gold/ChangeLog9
-rw-r--r--binutils-2.25/gold/aarch64.cc25
-rw-r--r--binutils-2.25/gold/options.h7
3 files changed, 40 insertions, 1 deletions
diff --git a/binutils-2.25/gold/ChangeLog b/binutils-2.25/gold/ChangeLog
index 24e87559..bf9cc55c 100644
--- a/binutils-2.25/gold/ChangeLog
+++ b/binutils-2.25/gold/ChangeLog
@@ -1,4 +1,11 @@
-2015-10.27 Han Shen <shenhan@google.com>
+2015-11-05 Cary Coutant <ccoutant@gmail.com>
+
+ PR gold/19163
+ * aarch64.cc (Target_aarch64::Relocate::relocate): Don't apply
+ certain relocations if --no-apply-dynamic-relocs is set.
+ * options.h (--apply-dynamic-relocs): New aarch64-specific option.
+
+2015-10-27 Han Shen <shenhan@google.com>
PR gold/19042 - unsupported reloc 311/312.
diff --git a/binutils-2.25/gold/aarch64.cc b/binutils-2.25/gold/aarch64.cc
index 1148bf7f..1cc68d1e 100644
--- a/binutils-2.25/gold/aarch64.cc
+++ b/binutils-2.25/gold/aarch64.cc
@@ -6907,16 +6907,41 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
break;
case elfcpp::R_AARCH64_ABS64:
+ if (!parameters->options().apply_dynamic_relocs()
+ && parameters->options().output_is_position_independent()
+ && gsym != NULL
+ && gsym->needs_dynamic_reloc(reloc_property->reference_flags())
+ && !gsym->can_use_relative_reloc(false))
+ // We have generated an absolute dynamic relocation, so do not
+ // apply the relocation statically. (Works around bugs in older
+ // Android dynamic linkers.)
+ break;
reloc_status = Reloc::template rela_ua<64>(
view, object, psymval, addend, reloc_property);
break;
case elfcpp::R_AARCH64_ABS32:
+ if (!parameters->options().apply_dynamic_relocs()
+ && parameters->options().output_is_position_independent()
+ && gsym != NULL
+ && gsym->needs_dynamic_reloc(reloc_property->reference_flags()))
+ // We have generated an absolute dynamic relocation, so do not
+ // apply the relocation statically. (Works around bugs in older
+ // Android dynamic linkers.)
+ break;
reloc_status = Reloc::template rela_ua<32>(
view, object, psymval, addend, reloc_property);
break;
case elfcpp::R_AARCH64_ABS16:
+ if (!parameters->options().apply_dynamic_relocs()
+ && parameters->options().output_is_position_independent()
+ && gsym != NULL
+ && gsym->needs_dynamic_reloc(reloc_property->reference_flags()))
+ // We have generated an absolute dynamic relocation, so do not
+ // apply the relocation statically. (Works around bugs in older
+ // Android dynamic linkers.)
+ break;
reloc_status = Reloc::template rela_ua<16>(
view, object, psymval, addend, reloc_property);
break;
diff --git a/binutils-2.25/gold/options.h b/binutils-2.25/gold/options.h
index 6502e1fc..db5254b8 100644
--- a/binutils-2.25/gold/options.h
+++ b/binutils-2.25/gold/options.h
@@ -644,6 +644,13 @@ class General_options
N_("Allow unresolved references in shared libraries"),
N_("Do not allow unresolved references in shared libraries"));
+ // Note: this is cherry-picked from upstream patch 0eccf19f9. But the default
+ // value is changed from "true" to "false".
+ DEFINE_bool(apply_dynamic_relocs, options::TWO_DASHES, '\0', false,
+ N_("Apply link-time values for dynamic relocations (default)"),
+ N_("(aarch64 only) Do not apply link-time values "
+ "for dynamic relocations"));
+
DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false,
N_("Only set DT_NEEDED for shared libraries if used"),
N_("Always DT_NEEDED for shared libraries"));