/* Xilinx MicroBlaze-specific support for 32-bit ELF
- Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
/* This reloc does nothing. */
HOWTO (R_MICROBLAZE_NONE, /* Type. */
0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
+ 0, /* Bitsize. */
FALSE, /* PC_relative. */
0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain on overflow. */
+ complain_overflow_dont, /* Complain on overflow. */
NULL, /* Special Function. */
"R_MICROBLAZE_NONE", /* Name. */
FALSE, /* Partial Inplace. */
/* This reloc does nothing. Used for relaxation. */
HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
+ 0, /* Bitsize. */
TRUE, /* PC_relative. */
0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain on overflow. */
+ complain_overflow_dont, /* Complain on overflow. */
NULL, /* Special Function. */
"R_MICROBLAZE_64_NONE",/* Name. */
FALSE, /* Partial Inplace. */
arelent * cache_ptr,
Elf_Internal_Rela * dst)
{
+ unsigned int r_type;
+
if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
/* Initialize howto table if needed. */
microblaze_elf_howto_init ();
- BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_MICROBLAZE_max);
+ r_type = ELF32_R_TYPE (dst->r_info);
+ if (r_type >= R_MICROBLAZE_max)
+ {
+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
+ abfd, r_type);
+ bfd_set_error (bfd_error_bad_value);
+ r_type = R_MICROBLAZE_NONE;
+ }
- cache_ptr->howto = microblaze_elf_howto_table [ELF32_R_TYPE (dst->r_info)];
+ cache_ptr->howto = microblaze_elf_howto_table [r_type];
}
/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */
howto = microblaze_elf_howto_table[r_type];
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
{
/* This is a relocatable link. We don't have to change
anything, unless the reloc is against a section symbol,
bfd_boolean dyn =
elf_hash_table (info)->dynamic_sections_created;
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
- && (!info->shared || !SYMBOL_REFERENCES_LOCAL (info, h)))
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
+ bfd_link_pic (info),
+ h)
+ && (!bfd_link_pic (info)
+ || !SYMBOL_REFERENCES_LOCAL (info, h)))
indx = h->dynindx;
}
/* Need to generate relocs ? */
- if ((info->shared || indx != 0)
+ if ((bfd_link_pic (info) || indx != 0)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
/* Process module-id */
if (IS_TLS_LD(tls_type))
{
- if (! info->shared)
+ if (! bfd_link_pic (info))
{
bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
}
/* Relocs for dyn symbols generated by
finish_dynamic_symbols */
- if (info->shared && h == NULL)
+ if (bfd_link_pic (info) && h == NULL)
{
*offp |= 1;
microblaze_elf_output_dynamic_relocation (output_bfd,
break;
}
- if ((info->shared
+ if ((bfd_link_pic (info)
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak)
&& h->dynindx != -1
&& (!info->symbolic
|| !h->def_regular))))
- || (!info->shared
+ || (!bfd_link_pic (info)
&& h != NULL
&& h->dynindx != -1
&& !h->non_got_ref
switch (r)
{
case bfd_reloc_overflow:
- if (!((*info->callbacks->reloc_overflow)
- (info, (h ? &h->root : NULL), name, howto->name,
- (bfd_vma) 0, input_bfd, input_section, offset)))
- return FALSE;
+ (*info->callbacks->reloc_overflow)
+ (info, (h ? &h->root : NULL), name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section, offset);
break;
case bfd_reloc_undefined:
- if (!((*info->callbacks->undefined_symbol)
- (info, name, input_bfd, input_section, offset, TRUE)))
- return FALSE;
+ (*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section, offset, TRUE);
break;
case bfd_reloc_outofrange:
errmsg = _("internal error: unknown error");
/* Fall through. */
common_error:
- if (!((*info->callbacks->warning)
- (info, errmsg, name, input_bfd, input_section, offset)))
- return FALSE;
+ (*info->callbacks->warning) (info, errmsg, name, input_bfd,
+ input_section, offset);
break;
}
}
*again = FALSE;
/* Only do this for a text section. */
- if (link_info->relocatable
+ if (bfd_link_relocatable (link_info)
|| (sec->flags & SEC_RELOC) == 0
|| (sec->reloc_count == 0)
|| (sec->flags & SEC_CODE) == 0)
struct elf32_mb_link_hash_table *htab;
asection *sreloc = NULL;
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
return TRUE;
htab = elf32_mb_hash_table (info);
case R_MICROBLAZE_64_PCREL:
case R_MICROBLAZE_32:
{
- if (h != NULL && !info->shared)
+ if (h != NULL && !bfd_link_pic (info))
{
/* we may need a copy reloc. */
h->non_got_ref = 1;
dynamic library if we manage to avoid copy relocs for the
symbol. */
- if ((info->shared
+ if ((bfd_link_pic (info)
&& (sec->flags & SEC_ALLOC) != 0
&& (r_type != R_MICROBLAZE_64_PCREL
|| (h != NULL
&& (! info->symbolic
|| h->root.type == bfd_link_hash_defweak
|| !h->def_regular))))
- || (!info->shared
+ || (!bfd_link_pic (info)
&& (sec->flags & SEC_ALLOC) != 0
&& h != NULL
&& (h->root.type == bfd_link_hash_defweak
htab->splt = bfd_get_linker_section (dynobj, ".plt");
htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
- if (!info->shared)
+ if (!bfd_link_pic (info))
htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
if (!htab->splt || !htab->srelplt || !htab->sdynbss
- || (!info->shared && !htab->srelbss))
+ || (!bfd_link_pic (info) && !htab->srelbss))
abort ();
return TRUE;
only references to the symbol are via the global offset table.
For such cases we need not do anything here; the relocations will
be handled correctly by relocate_section. */
- if (info->shared)
+ if (bfd_link_pic (info))
return TRUE;
/* If there are no references to this symbol that do not use the
return FALSE;
}
- if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
{
asection *s = htab->splt;
location in the .plt. This is required to make function
pointers compare as equal between the normal executable and
the shared library. */
- if (! info->shared
+ if (! bfd_link_pic (info)
&& !h->def_regular)
{
h->root.u.def.section = s;
space for pc-relative relocs that have become local due to symbol
visibility changes. */
- if (info->shared)
+ if (bfd_link_pic (info))
{
if (h->def_regular
&& (h->forced_local
/* Set up .got offsets for local syms, and space for local dynamic
relocs. */
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
bfd_signed_vma *local_got;
bfd_signed_vma *end_local_got;
{
*local_got = s->size;
s->size += need;
- if (info->shared)
+ if (bfd_link_pic (info))
srel->size += need * (sizeof (Elf32_External_Rela) / 4);
}
}
{
htab->tlsld_got.offset = htab->sgot->size;
htab->sgot->size += 8;
- if (info->shared)
+ if (bfd_link_pic (info))
htab->srelgot->size += sizeof (Elf32_External_Rela);
}
else
#define add_dynamic_entry(TAG, VAL) \
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
- if (info->executable)
+ if (bfd_link_executable (info))
{
if (!add_dynamic_entry (DT_DEBUG, 0))
return FALSE;
got_addr = got_offset;
/* For non-PIC objects we need absolute address of the GOT entry. */
- if (!info->shared)
+ if (!bfd_link_pic (info))
got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
/* Fill in the entry in the procedure linkage table. */
bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
splt->contents + h->plt.offset);
- if (info->shared)
+ if (bfd_link_pic (info))
bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1 + (got_addr & 0xffff),
splt->contents + h->plt.offset + 4);
else
BFD_ASSERT (sgot != NULL && srela != NULL);
offset = (sgot->output_section->vma + sgot->output_offset
- + (h->got.offset &~ (bfd_vma) 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. Likewise if
the symbol was forced to be local because of a version file.
The entry in the global offset table will already have been
initialized in the relocate_section function. */
- if (info->shared
- && (info->symbolic || h->dynindx == -1)
- && h->def_regular)
+ if (bfd_link_pic (info)
+ && ((info->symbolic && h->def_regular)
+ || h->dynindx == -1))
{
asection *sec = h->root.u.def.section;
microblaze_elf_output_dynamic_relocation (output_bfd,
{
asection *s;
- s = bfd_get_section_by_name (output_bfd, name);
+ s = bfd_get_linker_section (dynobj, name);
if (s == NULL)
dyn.d_un.d_val = 0;
else
{
if (! size)
- dyn.d_un.d_ptr = s->vma;
+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
else
dyn.d_un.d_val = s->size;
}
bfd_vma *valp)
{
if (sym->st_shndx == SHN_COMMON
- && !info->relocatable
+ && !bfd_link_relocatable (info)
&& sym->st_size <= elf_gp_size (abfd))
{
/* Common symbols less than or equal to -G nn bytes are automatically
return TRUE;
}
-#define TARGET_LITTLE_SYM bfd_elf32_microblazeel_vec
+#define TARGET_LITTLE_SYM microblaze_elf32_le_vec
#define TARGET_LITTLE_NAME "elf32-microblazeel"
-#define TARGET_BIG_SYM bfd_elf32_microblaze_vec
+#define TARGET_BIG_SYM microblaze_elf32_vec
#define TARGET_BIG_NAME "elf32-microblaze"
#define ELF_ARCH bfd_arch_microblaze