diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-03 09:25:51 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-03 09:25:51 -0700 |
commit | d4d8aee345704f7c39ebe9910cc08386708637b1 (patch) | |
tree | f5991b22c9669e94e28b62f58f3329a15a7e8c48 | |
parent | 58ee44efbc3798a8224e685aa47b224dc67efe7d (diff) | |
download | gdb-d4d8aee345704f7c39ebe9910cc08386708637b1.zip gdb-d4d8aee345704f7c39ebe9910cc08386708637b1.tar.gz gdb-d4d8aee345704f7c39ebe9910cc08386708637b1.tar.bz2 |
nios2: Call _bfd_elf_maybe_set_textrel to set DF_TEXTREL
Call _bfd_elf_maybe_set_textrel to set DF_TEXTREL by scanning dynamic
relocations in read-only section.
PR ld/26066
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Call
_bfd_elf_maybe_set_textrel to set DF_TEXTREL.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf32-nios2.c | 25 |
2 files changed, 21 insertions, 10 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 08f8a50..c9f46d6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,6 +1,12 @@ 2020-06-03 H.J. Lu <hongjiu.lu@intel.com> PR ld/26066 + * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Call + _bfd_elf_maybe_set_textrel to set DF_TEXTREL. + +2020-06-03 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/26066 * elf32-nios2.c (nios2_elf32_check_relocs): Skip non-loaded, non-alloced sections. diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 453b7cf..71200da 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -5761,8 +5761,6 @@ nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { srel = elf_section_data (p->sec)->sreloc; srel->size += p->count * sizeof (Elf32_External_Rela); - if ((p->sec->output_section->flags & SEC_READONLY) != 0) - info->flags |= DF_TEXTREL; } } } @@ -5911,17 +5909,24 @@ nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, || !add_dynamic_entry (DT_JMPREL, 0))) return FALSE; - if (relocs - && (!add_dynamic_entry (DT_RELA, 0) + if (relocs) + { + if (!add_dynamic_entry (DT_RELA, 0) || !add_dynamic_entry (DT_RELASZ, 0) - || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))) - return FALSE; + || !add_dynamic_entry (DT_RELAENT, + sizeof (Elf32_External_Rela))) + return FALSE; - if (!bfd_link_pic (info) && !add_dynamic_entry (DT_NIOS2_GP, 0)) - return FALSE; + if ((info->flags & DF_TEXTREL) == 0) + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); - if ((info->flags & DF_TEXTREL) != 0 - && !add_dynamic_entry (DT_TEXTREL, 0)) + if ((info->flags & DF_TEXTREL) != 0 + && !add_dynamic_entry (DT_TEXTREL, 0)) + return FALSE; + } + + if (!bfd_link_pic (info) && !add_dynamic_entry (DT_NIOS2_GP, 0)) return FALSE; } #undef add_dynamic_entry |