aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenlin Li <renlin.li@arm.com>2018-03-07 09:27:45 +0000
committerRenlin Li <renlin.li@arm.com>2018-03-07 14:47:27 +0000
commit0c1ded8dc0be9c61975e04a0b416b064223f7bda (patch)
treeea5508405d2eadfb08c3a9a45c323ee66fcb5915 /bfd/elfnn-aarch64.c
parentFix watching structs in C++ (diff)
downloadbinutils-gdb-0c1ded8dc0be9c61975e04a0b416b064223f7bda.tar.gz
binutils-gdb-0c1ded8dc0be9c61975e04a0b416b064223f7bda.tar.bz2
binutils-gdb-0c1ded8dc0be9c61975e04a0b416b064223f7bda.zip
[PR20402][LD][AARCH64]Don't emit RELATIVE relocation for absolute symbols which are resolved at static linking time.
For absolute symbols which are forced local or not dynamic, the ABS relocation should be resolved at static linking time. Originally, an RELATIVE/ABS relocation will be generated even for absolution symbols for the dynamic linker to resolve. bfd/ 2018-03-07 Renlin Li <renlin.li@arm.com> PR ld/20402 * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Check absolute symbol, and don't emit relocation in specific case. ld/ 2018-03-07 Renlin Li <renlin.li@arm.com> PR ld/20402 * testsuite/ld-aarch64/aarch64-elf.exp: Run new test. * testsuite/ld-aarch64/pr20402.s: New. * testsuite/ld-aarch64/pr20402.d: New.
Diffstat (limited to 'bfd/elfnn-aarch64.c')
-rw-r--r--bfd/elfnn-aarch64.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index dc24df801e2..beef91a22d0 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5074,6 +5074,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
asection *base_got;
bfd_vma orig_value = value;
bfd_boolean resolved_to_zero;
+ bfd_boolean abs_symbol_p;
globals = elf_aarch64_hash_table (info);
@@ -5093,6 +5094,9 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
weak_undef_p = (h ? h->root.type == bfd_link_hash_undefweak
: bfd_is_und_section (sym_sec));
+ abs_symbol_p = (h !=NULL && h->root.type == bfd_link_hash_defined
+ && bfd_is_abs_section (h->root.u.def.section));
+
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle
it here if it is defined in a non-shared object. */
@@ -5360,6 +5364,12 @@ bad_ifunc_reloc:
skip = TRUE;
relocate = TRUE;
}
+ else if (abs_symbol_p)
+ {
+ /* Local absolute symbol. */
+ skip = (h->forced_local || (h->dynindx == -1));
+ relocate = skip;
+ }
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
@@ -5369,8 +5379,7 @@ bad_ifunc_reloc:
else if (h != NULL
&& h->dynindx != -1
&& (!bfd_link_pic (info)
- || !(bfd_link_pie (info)
- || SYMBOLIC_BIND (info, h))
+ || !(bfd_link_pie (info) || SYMBOLIC_BIND (info, h))
|| !h->def_regular))
outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
else