/* Or1k-specific support for 32-bit ELF.
- Copyright (C) 2001-2016 Free Software Foundation, Inc.
+ Copyright (C) 2001-2017 Free Software Foundation, Inc.
Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org
PIC parts added by Stefan Kristiansson, stefan.kristiansson@saunalahti.fi,
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak));
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
- BFD_ASSERT (s != NULL);
-
rela.r_offset = (h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_COPY);
rela.r_addend = 0;
- loc = s->contents;
- loc += s->reloc_count * sizeof (Elf32_External_Rela);
+ if (h->root.u.def.section == htab->root.sdynrelro)
+ s = htab->root.sreldynrelro;
+ else
+ s = htab->root.srelbss;
+ loc = s->contents + s->reloc_count * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
++s->reloc_count;
}
struct elf_or1k_link_hash_entry *eh;
struct elf_or1k_dyn_relocs *p;
bfd *dynobj;
- asection *s;
+ asection *s, *srel;
dynobj = elf_hash_table (info)->dynobj;
if (htab == NULL)
return FALSE;
- s = htab->root.sdynbss;
- BFD_ASSERT (s != NULL);
-
/* We must generate a R_OR1K_COPY reloc to tell the dynamic linker
to copy the initial value out of the dynamic object and into the
runtime process image. We need to remember the offset into the
.rela.bss section we are going to use. */
- if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
+ if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
{
- asection *srel;
-
+ s = htab->root.sdynrelro;
+ srel = htab->root.sreldynrelro;
+ }
+ else
+ {
+ s = htab->root.sdynbss;
srel = htab->root.srelbss;
- BFD_ASSERT (srel != NULL);
+ }
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
+ {
srel->size += sizeof (Elf32_External_Rela);
h->needs_copy = 1;
}
if (s == htab->root.splt
|| s == htab->root.sgot
|| s == htab->root.sgotplt
- || s == htab->root.sdynbss)
+ || s == htab->root.sdynbss
+ || s == htab->root.sdynrelro)
{
/* Strip this section if we don't need it; see the
comment below. */
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 12
#define elf_backend_dtrel_excludes_plt 1
+#define elf_backend_want_dynrelro 1
#define bfd_elf32_bfd_link_hash_table_create or1k_elf_link_hash_table_create
#define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol