summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunlian Jiang <yunlian@google.com>2018-07-12 15:54:35 -0700
committerYunlian Jiang <yunlian@google.com>2018-07-12 15:54:35 -0700
commit49e1641cfc154895c5c5f394bb23c9518df2cb49 (patch)
tree3039fff4336786b009bcd15b1c4d402638901ae7
parentfcb56510b39e391c76f4931a64d19569024fbf1d (diff)
downloadbinutils-49e1641cfc154895c5c5f394bb23c9518df2cb49.tar.gz
Fix aarch64 --no-apply-dynamic-relocs option.android-n-iot-release-smart-display-r2
This option is intended to make gold not apply link-time values for absolution relocations which have dynamic relocations emitted for them, in order to workaround an android dynamic loader bug in old versions of android. Unfortunately, it also had the side-effect of breaking debug data, because the dynamic relocations are not used for non-ALLOC sections, but the flag was also suppressing the static relocation. This fix was proposed by jyknight@ and it fixed the problem by filtering out non-ALLOC sections with the --no-apply-dynamic-relocs option. BUG: 70838247 TEST: Debug info appears with --no-apply-dynamic-relocs
-rw-r--r--binutils-2.27/gold/aarch64.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/binutils-2.27/gold/aarch64.cc b/binutils-2.27/gold/aarch64.cc
index ebddeb6c..8cc44633 100644
--- a/binutils-2.27/gold/aarch64.cc
+++ b/binutils-2.27/gold/aarch64.cc
@@ -7024,7 +7024,7 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
const Relocate_info<size, big_endian>* relinfo,
unsigned int,
Target_aarch64<size, big_endian>* target,
- Output_section* ,
+ Output_section* output_section,
size_t relnum,
const unsigned char* preloc,
const Sized_symbol<size>* gsym,
@@ -7120,6 +7120,7 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
typename Reloc::Status reloc_status = Reloc::STATUS_OKAY;
typename elfcpp::Elf_types<size>::Elf_Addr value;
+ bool is_section_alloc = (output_section->flags() & elfcpp::SHF_ALLOC);
switch (r_type)
{
case elfcpp::R_AARCH64_NONE:
@@ -7128,6 +7129,7 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
case elfcpp::R_AARCH64_ABS64:
if (!parameters->options().apply_dynamic_relocs()
&& parameters->options().output_is_position_independent()
+ && is_section_alloc
&& gsym != NULL
&& gsym->needs_dynamic_reloc(reloc_property->reference_flags())
&& !gsym->can_use_relative_reloc(false))
@@ -7142,6 +7144,7 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
case elfcpp::R_AARCH64_ABS32:
if (!parameters->options().apply_dynamic_relocs()
&& parameters->options().output_is_position_independent()
+ && is_section_alloc
&& gsym != NULL
&& gsym->needs_dynamic_reloc(reloc_property->reference_flags()))
// We have generated an absolute dynamic relocation, so do not
@@ -7155,6 +7158,7 @@ Target_aarch64<size, big_endian>::Relocate::relocate(
case elfcpp::R_AARCH64_ABS16:
if (!parameters->options().apply_dynamic_relocs()
&& parameters->options().output_is_position_independent()
+ && is_section_alloc
&& gsym != NULL
&& gsym->needs_dynamic_reloc(reloc_property->reference_flags()))
// We have generated an absolute dynamic relocation, so do not