diff options
author | Jiong Wang <jiong.wang@arm.com> | 2015-06-23 12:12:06 +0100 |
---|---|---|
committer | Jiong Wang <jiong.wang@arm.com> | 2015-06-23 12:12:06 +0100 |
commit | c217058957a45a93481da35e1531ed120750d739 (patch) | |
tree | 9e94faaacc0df0173b25dcc96cbefff844ca98dd /bfd/elfnn-aarch64.c | |
parent | e5ee3fe285c698f1ce3d9bbb596bcda6219f5f3a (diff) | |
download | gdb-c217058957a45a93481da35e1531ed120750d739.zip gdb-c217058957a45a93481da35e1531ed120750d739.tar.gz gdb-c217058957a45a93481da35e1531ed120750d739.tar.bz2 |
[AArch64] Generate DT_TEXTREL for relocation against read-only section
2015-06-23 Jiong Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (aarch64_readonly_dynrelocs): New function.
(elfNN_aarch64_size_dynamic_sections): Traverse hash table to check
relocations against read-only sections.
ld/testsuite/
* ld-aarch64/dt_textrel.s: New testcase.
* ld-aarch64/dt_textrel.d: New expectation file.
* ld-aarch64/aarch64-elf.exp: Run new testcase.
Diffstat (limited to 'bfd/elfnn-aarch64.c')
-rw-r--r-- | bfd/elfnn-aarch64.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 1c55058..b13f5db 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -7545,6 +7545,32 @@ elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf) return elfNN_aarch64_allocate_ifunc_dynrelocs (h, inf); } +/* Find any dynamic relocs that apply to read-only sections. */ + +static bfd_boolean +aarch64_readonly_dynrelocs (struct elf_link_hash_entry * h, void * inf) +{ + struct elf_aarch64_link_hash_entry * eh; + struct elf_dyn_relocs * p; + + eh = (struct elf_aarch64_link_hash_entry *) h; + for (p = eh->dyn_relocs; p != NULL; p = p->next) + { + asection *s = p->sec; + + if (s != NULL && (s->flags & SEC_READONLY) != 0) + { + struct bfd_link_info *info = (struct bfd_link_info *) inf; + + info->flags |= DF_TEXTREL; + + /* Not an error, just cut short the traversal. */ + return FALSE; + } + } + return TRUE; +} + /* This is the most important function of all . Innocuosly named though ! */ static bfd_boolean @@ -7832,6 +7858,10 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ + if ((info->flags & DF_TEXTREL) == 0) + elf_link_hash_traverse (& htab->root, aarch64_readonly_dynrelocs, + info); + if ((info->flags & DF_TEXTREL) != 0) { if (!add_dynamic_entry (DT_TEXTREL, 0)) |