diff options
-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 08f8a50eede..c9f46d6d67d 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 453b7cf5a3d..71200da9b57 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 |