/* Meta support for 32-bit ELF
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
+ Copyright (C) 2013-2017 Free Software Foundation, Inc.
Contributed by Imagination Technologies Ltd.
This file is part of BFD, the Binary File Descriptor library.
asection **input_list;
Elf_Internal_Sym **all_local_syms;
- /* Short-cuts to get to dynamic linker sections. */
- asection *sdynbss;
- asection *srelbss;
-
/* Small local sym cache. */
struct sym_cache sym_cache;
htab->etab.hgot = eh;
- htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
- htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
-
return TRUE;
}
struct elf_metag_link_hash_table *htab;
struct elf_metag_link_hash_entry *hh;
struct elf_metag_dyn_reloc_entry *hdh_p;
- asection *s;
+ asection *s, *srel;
/* If this is a function, put it in the procedure linkage table. We
will fill in the contents of the procedure linkage table later,
/* We must generate a COPY reloc to tell the dynamic linker to
copy the initial value out of the dynamic object and into the
runtime process image. */
+ if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+ {
+ s = htab->etab.sdynrelro;
+ srel = htab->etab.sreldynrelro;
+ }
+ else
+ {
+ s = htab->etab.sdynbss;
+ srel = htab->etab.srelbss;
+ }
if ((eh->root.u.def.section->flags & SEC_ALLOC) != 0 && eh->size != 0)
{
- htab->srelbss->size += sizeof (Elf32_External_Rela);
+ srel->size += sizeof (Elf32_External_Rela);
eh->needs_copy = 1;
}
- s = htab->sdynbss;
-
return _bfd_elf_adjust_dynamic_copy (info, eh, s);
}
if (s == htab->etab.splt
|| s == htab->etab.sgot
|| s == htab->etab.sgotplt
- || s == htab->sdynbss)
+ || s == htab->etab.sdynbss
+ || s == htab->etab.sdynrelro)
{
/* Strip this section if we don't need it; see the
comment below. */
|| eh->root.type == bfd_link_hash_defweak)))
abort ();
- s = htab->srelbss;
-
rel.r_offset = (eh->root.u.def.value
+ eh->root.u.def.section->output_offset
+ eh->root.u.def.section->output_section->vma);
rel.r_addend = 0;
rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_COPY);
+ if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+ s = htab->etab.sreldynrelro;
+ else
+ s = htab->etab.srelbss;
loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
}
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
-
- case DT_RELASZ:
- /* Don't count procedure linkage table relocs in the
- overall reloc count. */
- if (htab->etab.srelplt) {
- s = htab->etab.srelplt;
- dyn.d_un.d_val -= s->size;
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_RELA:
- /* We may not be using the standard ELF linker script.
- If .rela.plt is the first .rela section, we adjust
- DT_RELA to not include it. */
- if (htab->etab.srelplt) {
- s = htab->etab.srelplt;
- if (dyn.d_un.d_ptr == s->output_section->vma + s->output_offset)
- dyn.d_un.d_ptr += s->size;
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
}
}
#define elf_backend_want_got_sym 0
#define elf_backend_want_plt_sym 0
#define elf_backend_plt_readonly 1
+#define elf_backend_dtrel_excludes_plt 1
+#define elf_backend_want_dynrelro 1
#define bfd_elf32_bfd_reloc_type_lookup metag_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup metag_reloc_name_lookup