diff options
Diffstat (limited to 'bfd/elf32-tic6x.c')
-rw-r--r-- | bfd/elf32-tic6x.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index c2b22ee..1ccbf9c 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1860,13 +1860,15 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, if (h->needs_copy) { Elf_Internal_Rela rel; + asection *s; /* This symbol needs a copy reloc. Set it up. */ if (h->dynindx == -1 || (h->root.type != bfd_link_hash_defined && h->root.type != bfd_link_hash_defweak) - || htab->elf.srelbss == NULL) + || htab->elf.srelbss == NULL + || htab->elf.sreldynrelro == NULL) abort (); rel.r_offset = (h->root.u.def.value @@ -1874,8 +1876,12 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, + h->root.u.def.section->output_offset); rel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_COPY); rel.r_addend = 0; + if ((h->root.u.def.section->flags & SEC_READONLY) != 0) + s = htab->elf.sreldynrelro; + else + s = htab->elf.srelbss; - elf32_tic6x_install_rela (output_bfd, htab->elf.srelbss, &rel); + elf32_tic6x_install_rela (output_bfd, s, &rel); } /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ @@ -2061,7 +2067,7 @@ elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info, { struct elf32_tic6x_link_hash_table *htab; bfd *dynobj; - asection *s; + asection *s, *srel; dynobj = elf_hash_table (info)->dynobj; @@ -2146,14 +2152,22 @@ elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info, /* We must generate a R_C6000_COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the runtime process image. */ + if ((h->root.u.def.section->flags & SEC_READONLY) != 0) + { + s = htab->elf.sdynrelro; + srel = htab->elf.sreldynrelro; + } + else + { + s = htab->elf.sdynbss; + srel = htab->elf.srelbss; + } if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) { - htab->elf.srelbss->size += sizeof (Elf32_External_Rela); + srel->size += sizeof (Elf32_External_Rela); h->needs_copy = 1; } - s = htab->elf.sdynbss; - return _bfd_elf_adjust_dynamic_copy (info, h, s); } @@ -3376,7 +3390,8 @@ elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) else if (s == htab->elf.splt || s == htab->elf.sgot || s == htab->elf.sgotplt - || s == htab->elf.sdynbss) + || s == htab->elf.sdynbss + || s == htab->elf.sdynrelro) { /* Strip this section if we don't need it; see the comment below. */ @@ -4369,6 +4384,7 @@ elf32_tic6x_write_section (bfd *output_bfd, #define elf_backend_can_refcount 1 #define elf_backend_want_got_plt 1 #define elf_backend_want_dynbss 1 +#define elf_backend_want_dynrelro 1 #define elf_backend_plt_readonly 1 #define elf_backend_rela_normal 1 #define elf_backend_got_header_size 8 |