diff options
Diffstat (limited to 'bfd/elfnn-riscv.c')
-rw-r--r-- | bfd/elfnn-riscv.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index db4b782..69907bd 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -862,7 +862,7 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct riscv_elf_link_hash_entry * eh; struct riscv_elf_dyn_relocs *p; bfd *dynobj; - asection *s; + asection *s, *srel; htab = riscv_elf_hash_table (info); BFD_ASSERT (htab != NULL); @@ -965,16 +965,26 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, to copy the initial value out of the dynamic object and into the runtime process image. We need to remember the offset into the .rel.bss section we are going to use. */ + 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 (ElfNN_External_Rela); + srel->size += sizeof (ElfNN_External_Rela); h->needs_copy = 1; } if (eh->tls_type & ~GOT_NORMAL) return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata); - return _bfd_elf_adjust_dynamic_copy (info, h, htab->elf.sdynbss); + return _bfd_elf_adjust_dynamic_copy (info, h, s); } /* Allocate space in .plt, .got and associated reloc sections for @@ -1328,7 +1338,8 @@ riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) 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. */ @@ -2389,6 +2400,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd, if (h->needs_copy) { Elf_Internal_Rela rela; + asection *s; /* This symbols needs a copy reloc. Set it up. */ BFD_ASSERT (h->dynindx != -1); @@ -2396,7 +2408,11 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd, rela.r_offset = sec_addr (h->root.u.def.section) + h->root.u.def.value; rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_COPY); rela.r_addend = 0; - riscv_elf_append_rela (output_bfd, htab->elf.srelbss, &rela); + if ((h->root.u.def.section->flags & SEC_READONLY) != 0) + s = htab->elf.sreldynrelro; + else + s = htab->elf.srelbss; + riscv_elf_append_rela (output_bfd, s, &rela); } /* Mark some specially defined symbols as absolute. */ @@ -3213,6 +3229,7 @@ riscv_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) #define elf_backend_plt_alignment 4 #define elf_backend_want_plt_sym 1 #define elf_backend_got_header_size (ARCH_SIZE / 8) +#define elf_backend_want_dynrelro 1 #define elf_backend_rela_normal 1 #define elf_backend_default_execstack 0 |