diff options
author | Cary Coutant <ccoutant@gmail.com> | 2015-11-05 12:24:14 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2015-11-05 12:24:14 -0800 |
commit | 0eccf19f96d6218dd7c2f8d13f0546c2b942cc08 (patch) | |
tree | 92d0c3a126be527683ecbbe4200d82d29e9fc15b /gold | |
parent | c86a40c6c2902b73ec6f601176820c760524afd2 (diff) | |
download | gdb-0eccf19f96d6218dd7c2f8d13f0546c2b942cc08.zip gdb-0eccf19f96d6218dd7c2f8d13f0546c2b942cc08.tar.gz gdb-0eccf19f96d6218dd7c2f8d13f0546c2b942cc08.tar.bz2 |
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.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 7 | ||||
-rw-r--r-- | gold/aarch64.cc | 25 | ||||
-rw-r--r-- | gold/options.h | 5 |
3 files changed, 37 insertions, 0 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 5aa49d4..e389438 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,10 @@ +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-11-03 Alan Modra <amodra@gmail.com> * po/POTFILES.in: Regenerate. diff --git a/gold/aarch64.cc b/gold/aarch64.cc index 2dcd620..bc85c83 100644 --- a/gold/aarch64.cc +++ b/gold/aarch64.cc @@ -6911,16 +6911,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/gold/options.h b/gold/options.h index 4d65225..5756014 100644 --- a/gold/options.h +++ b/gold/options.h @@ -644,6 +644,11 @@ class General_options N_("Allow unresolved references in shared libraries"), N_("Do not allow unresolved references in shared libraries")); + DEFINE_bool(apply_dynamic_relocs, options::TWO_DASHES, '\0', true, + 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")); |