/* M32R-specific support for 32-bit ELF.
- Copyright (C) 1996-2019 Free Software Foundation, Inc.
+ Copyright (C) 1996-2021 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
asection *sec,
int *retval)
{
- if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ if (strcmp (bfd_section_name (sec), ".scommon") == 0)
{
*retval = SHN_M32R_SCOMMON;
return TRUE;
_SDA_BASE. This is what we use for the small common section. This
approach is copied from elf32-mips.c. */
static asection m32r_elf_scom_section;
-static asymbol m32r_elf_scom_symbol;
-static asymbol *m32r_elf_scom_symbol_ptr;
+static const asymbol m32r_elf_scom_symbol =
+ GLOBAL_SYM_INIT (".scommon", &m32r_elf_scom_section);
+static asection m32r_elf_scom_section =
+ BFD_FAKE_SECTION (m32r_elf_scom_section, &m32r_elf_scom_symbol,
+ ".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
/* Handle the special M32R section numbers that a symbol may use. */
switch (elfsym->internal_elf_sym.st_shndx)
{
case SHN_M32R_SCOMMON:
- if (m32r_elf_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- m32r_elf_scom_section.name = ".scommon";
- m32r_elf_scom_section.flags = SEC_IS_COMMON;
- m32r_elf_scom_section.output_section = &m32r_elf_scom_section;
- m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol;
- m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr;
- m32r_elf_scom_symbol.name = ".scommon";
- m32r_elf_scom_symbol.flags = BSF_SECTION_SYM;
- m32r_elf_scom_symbol.section = &m32r_elf_scom_section;
- m32r_elf_scom_symbol_ptr = &m32r_elf_scom_symbol;
- }
asym->section = &m32r_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size;
break;
flags);
if (s == NULL)
return FALSE;
- if (! bfd_set_section_alignment (abfd, s, 2))
+ if (!bfd_set_section_alignment (s, 2))
return FALSE;
}
{
case SHN_M32R_SCOMMON:
*secp = bfd_make_section_old_way (abfd, ".scommon");
- (*secp)->flags |= SEC_IS_COMMON;
+ (*secp)->flags |= SEC_IS_COMMON | SEC_SMALL_DATA;
*valp = sym->st_size;
break;
}
bfd_size_type count;
};
-/* m32r ELF linker hash entry. */
-
-struct elf_m32r_link_hash_entry
-{
- struct elf_link_hash_entry root;
-
- /* Track dynamic relocs copied for this symbol. */
- struct elf_dyn_relocs *dyn_relocs;
-};
-
-/* m32r ELF linker hash table. */
-
-struct elf_m32r_link_hash_table
-{
- struct elf_link_hash_table root;
-
- /* Short-cuts to get to dynamic linker sections. */
- asection *sdynbss;
- asection *srelbss;
-
- /* Small local sym cache. */
- struct sym_cache sym_cache;
-};
-
/* Traverse an m32r ELF linker hash table. */
#define m32r_elf_link_hash_traverse(table, func, info) \
/* Get the m32r ELF linker hash table from a link_info structure. */
#define m32r_elf_hash_table(p) \
- (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
- == M32R_ELF_DATA ? ((struct elf_m32r_link_hash_table *) ((p)->hash)) : NULL)
-
-/* Create an entry in an m32r ELF linker hash table. */
-
-static struct bfd_hash_entry *
-m32r_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
-{
- struct elf_m32r_link_hash_entry *ret =
- (struct elf_m32r_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == NULL)
- ret = bfd_hash_allocate (table,
- sizeof (struct elf_m32r_link_hash_entry));
- if (ret == NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct elf_m32r_link_hash_entry *)
- _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != NULL)
- {
- struct elf_m32r_link_hash_entry *eh;
-
- eh = (struct elf_m32r_link_hash_entry *) ret;
- eh->dyn_relocs = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
+ ((is_elf_hash_table ((p)->hash) \
+ && elf_hash_table_id (elf_hash_table (p)) == M32R_ELF_DATA) \
+ ? (struct elf_link_hash_table *) (p)->hash : NULL)
/* Create an m32r ELF linker hash table. */
static struct bfd_link_hash_table *
m32r_elf_link_hash_table_create (bfd *abfd)
{
- struct elf_m32r_link_hash_table *ret;
- bfd_size_type amt = sizeof (struct elf_m32r_link_hash_table);
+ struct elf_link_hash_table *ret;
+ size_t amt = sizeof (struct elf_link_hash_table);
ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
- m32r_elf_link_hash_newfunc,
- sizeof (struct elf_m32r_link_hash_entry),
+ if (!_bfd_elf_link_hash_table_init (ret, abfd,
+ _bfd_elf_link_hash_newfunc,
+ sizeof (struct elf_link_hash_entry),
M32R_ELF_DATA))
{
free (ret);
return NULL;
}
- return &ret->root.root;
+ return &ret->root;
}
/* Create dynamic sections when linking against a dynamic object. */
static bfd_boolean
m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
{
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
flagword flags, pltflags;
asection *s;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
pltflags |= SEC_READONLY;
s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
- htab->root.splt = s;
+ htab->splt = s;
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+ || !bfd_set_section_alignment (s, bed->plt_alignment))
return FALSE;
if (bed->want_plt_sym)
h = (struct elf_link_hash_entry *) bh;
h->def_regular = 1;
h->type = STT_OBJECT;
- htab->root.hplt = h;
+ htab->hplt = h;
if (bfd_link_pic (info)
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
bed->default_use_rela_p
? ".rela.plt" : ".rel.plt",
flags | SEC_READONLY);
- htab->root.srelplt = s;
+ htab->srelplt = s;
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, ptralign))
+ || !bfd_set_section_alignment (s, ptralign))
return FALSE;
- if (htab->root.sgot == NULL
+ if (htab->sgot == NULL
&& !_bfd_elf_create_got_section (abfd, info))
return FALSE;
flags | SEC_READONLY);
htab->srelbss = s;
if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, ptralign))
+ || !bfd_set_section_alignment (s, ptralign))
return FALSE;
}
}
return TRUE;
}
-/* Copy the extra info we tack onto an elf_link_hash_entry. */
-
-static void
-m32r_elf_copy_indirect_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *dir,
- struct elf_link_hash_entry *ind)
-{
- struct elf_m32r_link_hash_entry * edir;
- struct elf_m32r_link_hash_entry * eind;
-
- edir = (struct elf_m32r_link_hash_entry *) dir;
- eind = (struct elf_m32r_link_hash_entry *) ind;
-
- if (eind->dyn_relocs != NULL)
- {
- if (edir->dyn_relocs != NULL)
- {
- struct elf_dyn_relocs **pp;
- struct elf_dyn_relocs *p;
-
- /* Add reloc counts against the indirect sym to the direct sym
- list. Merge any entries against the same section. */
- for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
- {
- struct elf_dyn_relocs *q;
-
- for (q = edir->dyn_relocs; q != NULL; q = q->next)
- if (q->sec == p->sec)
- {
- q->pc_count += p->pc_count;
- q->count += p->count;
- *pp = p->next;
- break;
- }
- if (q == NULL)
- pp = &p->next;
- }
- *pp = edir->dyn_relocs;
- }
-
- edir->dyn_relocs = eind->dyn_relocs;
- eind->dyn_relocs = NULL;
- }
-
- _bfd_elf_link_hash_copy_indirect (info, dir, ind);
-}
-
\f
-/* Find dynamic relocs for H that apply to read-only sections. */
-
-static asection *
-readonly_dynrelocs (struct elf_link_hash_entry *h)
-{
- struct elf_dyn_relocs *p;
- struct elf_m32r_link_hash_entry *eh = (struct elf_m32r_link_hash_entry *) h;
-
- for (p = eh->dyn_relocs; p != NULL; p = p->next)
- {
- asection *s = p->sec->output_section;
-
- if (s != NULL && (s->flags & SEC_READONLY) != 0)
- return p->sec;
- }
- return NULL;
-}
-
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
bfd *dynobj;
asection *s;
/* If we don't find any dynamic relocs in read-only sections, then
we'll be keeping the dynamic relocs and avoiding the copy reloc. */
- if (0 && !readonly_dynrelocs (h))
+ if (0 && !_bfd_elf_readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct bfd_link_info *info;
- struct elf_m32r_link_hash_table *htab;
- struct elf_m32r_link_hash_entry *eh;
+ struct elf_link_hash_table *htab;
struct elf_dyn_relocs *p;
if (h->root.type == bfd_link_hash_indirect)
if (htab == NULL)
return FALSE;
- eh = (struct elf_m32r_link_hash_entry *) h;
-
- if (htab->root.dynamic_sections_created
+ if (htab->dynamic_sections_created
&& h->plt.refcount > 0)
{
/* Make sure this symbol is output as a dynamic symbol.
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
{
- asection *s = htab->root.splt;
+ asection *s = htab->splt;
/* If this is the first .plt entry, make room for the special
first entry. */
/* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */
- htab->root.sgotplt->size += 4;
+ htab->sgotplt->size += 4;
/* We also need to make an entry in the .rel.plt section. */
- htab->root.srelplt->size += sizeof (Elf32_External_Rela);
+ htab->srelplt->size += sizeof (Elf32_External_Rela);
}
else
{
return FALSE;
}
- s = htab->root.sgot;
+ s = htab->sgot;
h->got.offset = s->size;
s->size += 4;
- dyn = htab->root.dynamic_sections_created;
+ dyn = htab->dynamic_sections_created;
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
- htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+ htab->srelgot->size += sizeof (Elf32_External_Rela);
}
else
h->got.offset = (bfd_vma) -1;
- if (eh->dyn_relocs == NULL)
+ if (h->dyn_relocs == NULL)
return TRUE;
/* In the shared -Bsymbolic case, discard space allocated for
{
struct elf_dyn_relocs **pp;
- for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
+ for (pp = &h->dyn_relocs; (p = *pp) != NULL;)
{
p->count -= p->pc_count;
p->pc_count = 0;
/* Also discard relocs on undefined weak syms with non-default
visibility. */
- if (eh->dyn_relocs != NULL
+ if (h->dyn_relocs != NULL
&& h->root.type == bfd_link_hash_undefweak)
{
if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
- eh->dyn_relocs = NULL;
+ h->dyn_relocs = NULL;
/* Make sure undefined weak symbols are output as a dynamic
symbol in PIEs. */
if (!h->non_got_ref
&& ((h->def_dynamic
&& !h->def_regular)
- || (htab->root.dynamic_sections_created
+ || (htab->dynamic_sections_created
&& (h->root.type == bfd_link_hash_undefweak
|| h->root.type == bfd_link_hash_undefined))))
{
goto keep;
}
- eh->dyn_relocs = NULL;
+ h->dyn_relocs = NULL;
keep: ;
}
/* Finally, allocate space. */
- for (p = eh->dyn_relocs; p != NULL; p = p->next)
+ for (p = h->dyn_relocs; p != NULL; p = p->next)
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
sreloc->size += p->count * sizeof (Elf32_External_Rela);
return TRUE;
}
-/* Set DF_TEXTREL if we find any dynamic relocs that apply to
- read-only sections. */
-
-static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
-{
- asection *sec;
-
- if (h->root.type == bfd_link_hash_indirect)
- return TRUE;
-
- sec = readonly_dynrelocs (h);
- if (sec != NULL)
- {
- struct bfd_link_info *info = (struct bfd_link_info *) info_p;
-
- info->flags |= DF_TEXTREL;
- info->callbacks->minfo
- (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"),
- sec->owner, h->root.root.string, sec);
-
- /* Not an error, just cut short the traversal. */
- return FALSE;
- }
- return TRUE;
-}
-
/* Set the sizes of the dynamic sections. */
static bfd_boolean
m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info)
{
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
bfd *dynobj;
asection *s;
bfd_boolean relocs;
if (htab == NULL)
return FALSE;
- dynobj = htab->root.dynobj;
+ dynobj = htab->dynobj;
BFD_ASSERT (dynobj != NULL);
- if (htab->root.dynamic_sections_created)
+ if (htab->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
if (bfd_link_executable (info) && !info->nointerp)
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount;
- s = htab->root.sgot;
- srel = htab->root.srelgot;
+ s = htab->sgot;
+ srel = htab->srelgot;
for (; local_got < end_local_got; ++local_got)
{
if (*local_got > 0)
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
- elf_link_hash_traverse (&htab->root, allocate_dynrelocs, info);
+ elf_link_hash_traverse (htab, allocate_dynrelocs, info);
/* We now have determined the sizes of the various dynamic sections.
Allocate memory for them. */
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
- if (s == htab->root.splt
- || s == htab->root.sgot
- || s == htab->root.sgotplt
+ if (s == htab->splt
+ || s == htab->sgot
+ || s == htab->sgotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
comment below. */
}
- else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
+ else if (startswith (bfd_section_name (s), ".rela"))
{
- if (s->size != 0 && s != htab->root.srelplt)
+ if (s->size != 0 && s != htab->srelplt)
relocs = TRUE;
/* We use the reloc_count field as a counter if we need
return FALSE;
}
- if (htab->root.dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in m32r_elf_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
-#define add_dynamic_entry(TAG, VAL) \
- _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
- if (bfd_link_executable (info))
- {
- if (! add_dynamic_entry (DT_DEBUG, 0))
- return FALSE;
- }
-
- if (htab->root.splt->size != 0)
- {
- if (! add_dynamic_entry (DT_PLTGOT, 0)
- || ! add_dynamic_entry (DT_PLTRELSZ, 0)
- || ! add_dynamic_entry (DT_PLTREL, DT_RELA)
- || ! add_dynamic_entry (DT_JMPREL, 0))
- return FALSE;
- }
-
- 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;
-
- /* If any dynamic relocs apply to a read-only section,
- then we need a DT_TEXTREL entry. */
- if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->root, maybe_set_textrel, info);
-
- if ((info->flags & DF_TEXTREL) != 0)
- {
- if (! add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- }
- }
- }
-#undef add_dynamic_entry
-
- return TRUE;
+ return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
}
/* Relocate an M32R/D ELF section.
Elf_Internal_Rela *rel, *relend;
/* Assume success. */
bfd_boolean ret = TRUE;
- struct elf_m32r_link_hash_table *htab = m32r_elf_hash_table (info);
+ struct elf_link_hash_table *htab = m32r_elf_hash_table (info);
bfd_vma *local_got_offsets;
asection *sgot, *splt, *sreloc;
bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section);
local_got_offsets = elf_local_got_offsets (input_bfd);
- sgot = htab->root.sgot;
- splt = htab->root.splt;
+ sgot = htab->sgot;
+ splt = htab->splt;
sreloc = NULL;
rel = relocs;
bfd_boolean dyn;
sec = h->root.u.def.section;
- dyn = htab->root.dynamic_sections_created;
+ dyn = htab->dynamic_sections_created;
sec = h->root.u.def.section;
if (r_type == R_M32R_GOTPC24
|| (r_type == R_M32R_GOTPC_HI_ULO
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else if (!bfd_link_relocatable (info))
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (h->other)));
- }
+ info->callbacks->undefined_symbol
+ (info, h->root.root.string, input_bfd, input_section, offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (h->other));
+ }
if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
off = h->got.offset;
BFD_ASSERT (off != (bfd_vma) -1);
- dyn = htab->root.dynamic_sections_created;
+ dyn = htab->dynamic_sections_created;
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
bfd_link_pic (info),
h)
/* We need to generate a R_M32R_RELATIVE reloc
for the dynamic linker. */
- srelgot = htab->root.srelgot;
+ srelgot = htab->srelgot;
BFD_ASSERT (srelgot != NULL);
outrel.r_offset = (sgot->output_section->vma
const char *name;
BFD_ASSERT (sec != NULL);
- name = bfd_get_section_name (sec->owner, sec);
+ name = bfd_section_name (sec);
if ( strcmp (name, ".sdata") == 0
|| strcmp (name, ".sbss") == 0
name = (bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name));
if (name == NULL || *name == '\0')
- name = bfd_section_name (input_bfd, sec);
+ name = bfd_section_name (sec);
}
if (errmsg != NULL)
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
bfd_byte *loc;
#ifdef DEBUG_PIC
BFD_ASSERT (h->dynindx != -1);
- splt = htab->root.splt;
- sgot = htab->root.sgotplt;
- srela = htab->root.srelplt;
+ splt = htab->splt;
+ sgot = htab->sgotplt;
+ srela = htab->srelplt;
BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
/* Get the index in the procedure linkage table which
/* This symbol has an entry in the global offset table. Set it
up. */
- sgot = htab->root.sgot;
- srela = htab->root.srelgot;
+ sgot = htab->sgot;
+ srela = htab->srelgot;
BFD_ASSERT (sgot != NULL && srela != NULL);
rela.r_offset = (sgot->output_section->vma
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak));
- s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
+ s = bfd_get_linker_section (htab->dynobj, ".rela.bss");
BFD_ASSERT (s != NULL);
rela.r_offset = (h->root.u.def.value
}
/* Mark some specially defined symbols as absolute. */
- if (h == htab->root.hdynamic || h == htab->root.hgot)
+ if (h == htab->hdynamic || h == htab->hgot)
sym->st_shndx = SHN_ABS;
return TRUE;
m32r_elf_finish_dynamic_sections (bfd *output_bfd,
struct bfd_link_info *info)
{
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
bfd *dynobj;
asection *sdyn;
asection *sgot;
if (htab == NULL)
return FALSE;
- dynobj = htab->root.dynobj;
+ dynobj = htab->dynobj;
- sgot = htab->root.sgotplt;
+ sgot = htab->sgotplt;
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
- if (htab->root.dynamic_sections_created)
+ if (htab->dynamic_sections_created)
{
asection *splt;
Elf32_External_Dyn *dyncon, *dynconend;
break;
case DT_PLTGOT:
- s = htab->root.sgotplt;
+ s = htab->sgotplt;
goto get_vma;
case DT_JMPREL:
- s = htab->root.srelplt;
+ s = htab->srelplt;
get_vma:
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = htab->root.srelplt;
+ s = htab->srelplt;
dyn.d_un.d_val = s->size;
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
}
/* Fill in the first entry in the procedure linkage table. */
- splt = htab->root.splt;
+ splt = htab->splt;
if (splt && splt->size > 0)
{
if (bfd_link_pic (info))
/* Store the machine number in the flags field. */
-static void
-m32r_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
+static bfd_boolean
+m32r_elf_final_write_processing (bfd *abfd)
{
unsigned long val;
elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH;
elf_elfheader (abfd)->e_flags |= val;
- _bfd_elf_final_write_processing (abfd, linker);
+ return _bfd_elf_final_write_processing (abfd);
}
/* Function to keep M32R specific file flags. */
struct elf_link_hash_entry **sym_hashes;
const Elf_Internal_Rela *rel;
const Elf_Internal_Rela *rel_end;
- struct elf_m32r_link_hash_table *htab;
+ struct elf_link_hash_table *htab;
bfd *dynobj;
asection *sreloc;
if (bfd_link_relocatable (info))
return TRUE;
- /* Don't do anything special with non-loaded, non-alloced sections.
- In particular, any relocs in such sections should not affect GOT
- and PLT reference counting (ie. we don't allow them to create GOT
- or PLT entries), there's no possibility or desire to optimize TLS
- relocs, and there's not much point in propagating relocs to shared
- libs that the dynamic linker won't relocate. */
- if ((sec->flags & SEC_ALLOC) == 0)
- return TRUE;
-
sreloc = NULL;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
if (htab == NULL)
return FALSE;
- dynobj = htab->root.dynobj;
+ dynobj = htab->dynobj;
rel_end = relocs + sec->reloc_count;
for (rel = relocs; rel < rel_end; rel++)
}
/* Some relocs require a global offset table. */
- if (htab->root.sgot == NULL)
+ if (htab->sgot == NULL)
{
switch (r_type)
{
case R_M32R_GOTPC_LO:
case R_M32R_GOT24:
if (dynobj == NULL)
- htab->root.dynobj = dynobj = abfd;
+ htab->dynobj = dynobj = abfd;
if (!_bfd_elf_create_got_section (dynobj, info))
return FALSE;
break;
struct elf_dyn_relocs **head;
if (dynobj == NULL)
- htab->root.dynobj = dynobj = abfd;
+ htab->dynobj = dynobj = abfd;
/* When creating a shared object, we must copy these
relocs into the output file. We create a reloc
/* If this is a global symbol, we count the number of
relocations we need for this symbol. */
if (h != NULL)
- head = &((struct elf_m32r_link_hash_entry *) h)->dyn_relocs;
+ head = &h->dyn_relocs;
else
{
/* Track dynamic relocs needed for local syms too. */
p = *head;
if (p == NULL || p->sec != sec)
{
- bfd_size_type amt = sizeof (*p);
+ size_t amt = sizeof (*p);
p = bfd_alloc (dynobj, amt);
if (p == NULL)
{ NULL, 0, 0, 0, 0 }
};
+static bfd_boolean
+m32r_elf_section_flags (const Elf_Internal_Shdr *hdr)
+{
+ const char *name = hdr->bfd_section->name;
+
+ if (strncmp (name, ".sbss", 5) == 0
+ || strncmp (name, ".sdata", 6) == 0)
+ hdr->bfd_section->flags |= SEC_SMALL_DATA;
+
+ return TRUE;
+}
+
static enum elf_reloc_type_class
m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
const asection *rel_sec ATTRIBUTE_UNUSED,
#define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol
#define elf_backend_finish_dynamic_symbol m32r_elf_finish_dynamic_symbol
#define elf_backend_reloc_type_class m32r_elf_reloc_type_class
-#define elf_backend_copy_indirect_symbol m32r_elf_copy_indirect_symbol
#define elf_backend_can_gc_sections 1
/*#if !USE_REL
#define bfd_elf32_bfd_set_private_flags m32r_elf_set_private_flags
#define bfd_elf32_bfd_print_private_bfd_data m32r_elf_print_private_bfd_data
#define elf_backend_special_sections m32r_elf_special_sections
+#define elf_backend_section_flags m32r_elf_section_flags
#define elf_backend_linux_prpsinfo32_ugid16 TRUE