#include "elf-bfd.h"
#include "elf/sh.h"
#include "libiberty.h"
+#include "../opcodes/sh-opc.h"
static bfd_reloc_status_type sh_elf_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
(bfd *, asection *, bfd_vma, int);
static bfd_boolean sh_elf_align_loads
(bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, bfd_boolean *);
+#ifndef SH64_ELF
static bfd_boolean sh_elf_swap_insns
(bfd *, asection *, void *, bfd_byte *, bfd_vma);
+#endif
static bfd_boolean sh_elf_relocate_section
(bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
#ifdef INCLUDE_SHMEDIA
inline static void movi_shori_putval (bfd *, unsigned long, char *);
#endif
+#if !defined SH_TARGET_ALREADY_DEFINED
static bfd_boolean elf32_shlin_grok_prstatus
(bfd *abfd, Elf_Internal_Note *note);
static bfd_boolean elf32_shlin_grok_psinfo
(bfd *abfd, Elf_Internal_Note *note);
+#endif
/* The name of the dynamic interpreter. This is put in the .interp
section. */
laddr = irel->r_offset + 4 + irel->r_addend;
if (laddr >= sec->size)
{
- (*_bfd_error_handler) (_("%s: 0x%lx: warning: bad R_SH_USES offset"),
- bfd_archive_filename (abfd),
+ (*_bfd_error_handler) (_("%B: 0x%lx: warning: bad R_SH_USES offset"),
+ abfd,
(unsigned long) irel->r_offset);
continue;
}
if ((insn & 0xf000) != 0xd000)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
- bfd_archive_filename (abfd), (unsigned long) irel->r_offset, insn));
+ (_("%B: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"),
+ abfd, (unsigned long) irel->r_offset, insn));
continue;
}
if (paddr >= sec->size)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: warning: bad R_SH_USES load offset"),
- bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+ (_("%B: 0x%lx: warning: bad R_SH_USES load offset"),
+ abfd, (unsigned long) irel->r_offset));
continue;
}
if (irelfn >= irelend)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: warning: could not find expected reloc"),
- bfd_archive_filename (abfd), (unsigned long) paddr));
+ (_("%B: 0x%lx: warning: could not find expected reloc"),
+ abfd, (unsigned long) paddr));
continue;
}
!= (unsigned int) _bfd_elf_section_from_bfd_section (abfd, sec))
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: warning: symbol in unexpected section"),
- bfd_archive_filename (abfd), (unsigned long) paddr));
+ (_("%B: 0x%lx: warning: symbol in unexpected section"),
+ abfd, (unsigned long) paddr));
continue;
}
if (irelcount >= irelend)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: warning: could not find expected COUNT reloc"),
- bfd_archive_filename (abfd), (unsigned long) paddr));
+ (_("%B: 0x%lx: warning: could not find expected COUNT reloc"),
+ abfd, (unsigned long) paddr));
continue;
}
just deleted one. */
if (irelcount->r_addend == 0)
{
- ((*_bfd_error_handler) (_("%s: 0x%lx: warning: bad count"),
- bfd_archive_filename (abfd),
+ ((*_bfd_error_handler) (_("%B: 0x%lx: warning: bad count"),
+ abfd,
(unsigned long) paddr));
continue;
}
if (overflow)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
- bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+ (_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
+ abfd, (unsigned long) irel->r_offset));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
return FALSE;
}
+#ifndef SH64_ELF
/* Swap two SH instructions. This is like sh_swap_insns in coff-sh.c. */
static bfd_boolean
if (overflow)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
- bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
+ (_("%B: 0x%lx: fatal: reloc overflow while relaxing"),
+ abfd, (unsigned long) irel->r_offset));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
return TRUE;
}
+#endif /* defined SH64_ELF */
\f
#ifdef INCLUDE_SHMEDIA
if (howto->rightshift || howto->src_mask != 0xffffffff)
{
(*_bfd_error_handler)
- (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
- bfd_archive_filename (input_bfd),
- bfd_get_section_name (input_bfd, input_section),
+ (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"),
+ input_bfd, input_section,
(long) rel->r_offset, howto->name);
return FALSE;
}
else if (sec->output_section == NULL)
{
(*_bfd_error_handler)
- (_("%s: unresolvable relocation against symbol `%s' from %s section"),
- bfd_archive_filename (input_bfd), h->root.root.string,
- bfd_get_section_name (input_bfd, input_section));
+ (_("%B(%A): unresolvable relocation against symbol `%s'"),
+ input_bfd, input_section, h->root.root.string);
return FALSE;
}
else
if (disp & mask)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: unaligned branch target for relax-support relocation"),
- bfd_archive_filename (input_section->owner),
+ (_("%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"),
+ input_section->owner,
(unsigned long) rel->r_offset));
bfd_set_error (bfd_error_bad_value);
return FALSE;
if (relocation & 3)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
- bfd_archive_filename (input_section->owner),
+ (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ input_section->owner,
(unsigned long) rel->r_offset, howto->name,
- (unsigned long)relocation));
+ (unsigned long) relocation));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
if (relocation & 1)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
- bfd_archive_filename (input_section->owner),
+ (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ input_section->owner,
(unsigned long) rel->r_offset, howto->name,
- (unsigned long)relocation));
+ (unsigned long) relocation));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
|| (signed int)relocation > 32)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
- bfd_archive_filename (input_section->owner),
+ (_("%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
+ input_section->owner,
(unsigned long) rel->r_offset,
- (unsigned long)relocation));
+ (unsigned long) relocation));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
|| (signed int)relocation > 16)
{
((*_bfd_error_handler)
- (_("%s: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
- bfd_archive_filename (input_section->owner),
+ (_("%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
+ input_section->owner,
(unsigned long) rel->r_offset,
- (unsigned long)relocation));
+ (unsigned long) relocation));
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
else
{
(*_bfd_error_handler)
- (_("%s: `%s' accessed both as normal and thread local symbol"),
- bfd_archive_filename (abfd), h->root.root.string);
+ (_("%B: `%s' accessed both as normal and thread local symbol"),
+ abfd, h->root.root.string);
return FALSE;
}
}
case R_SH_TLS_LE_32:
if (info->shared)
{
- (*_bfd_error_handler) (_("%s: TLS local exec code cannot be linked into shared objects"),
- bfd_archive_filename (abfd));
+ (*_bfd_error_handler)
+ (_("%B: TLS local exec code cannot be linked into shared objects"),
+ abfd);
return FALSE;
}
/* This function returns the ELF architecture number that
corresponds to the given arch_sh* flags. */
+
int
sh_find_elf_flags (unsigned int arch_set)
{
+ extern unsigned long sh_get_bfd_mach_from_arch_set (unsigned int);
unsigned long bfd_mach = sh_get_bfd_mach_from_arch_set (arch_set);
return sh_elf_get_flags_from_mach (bfd_mach);
}
-
/* This routine initialises the elf flags when required and
calls sh_merge_bfd_arch() to check dsp/fpu compatibility. */
static bfd_boolean
sh_elf_merge_private_data (bfd *ibfd, bfd *obfd)
{
+ extern bfd_boolean sh_merge_bfd_arch (bfd *, bfd *);
+
if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
sh_elf_set_mach_from_flags (obfd);
}
- if ( ! sh_merge_bfd_arch (ibfd, obfd) )
- return FALSE;
+ if (! sh_merge_bfd_arch (ibfd, obfd))
+ {
+ _bfd_error_handler ("%B: uses instructions which are incompatible "
+ "with instructions used in previous modules",
+ ibfd);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
elf_elfheader (obfd)->e_flags =
sh_elf_get_flags_from_mach (bfd_get_mach (obfd));
}
}
+#if !defined SH_TARGET_ALREADY_DEFINED
/* Support for Linux core dump NOTE sections. */
+
static bfd_boolean
elf32_shlin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
return TRUE;
}
+#endif /* not SH_TARGET_ALREADY_DEFINED */
/* Return address for Ith PLT stub in section PLT, for relocation REL
return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
}
+#if !defined SH_TARGET_ALREADY_DEFINED
#define TARGET_BIG_SYM bfd_elf32_sh_vec
#define TARGET_BIG_NAME "elf32-sh"
#define TARGET_LITTLE_SYM bfd_elf32_shl_vec
#define TARGET_LITTLE_NAME "elf32-shl"
+#endif
+
#define ELF_ARCH bfd_arch_sh
#define ELF_MACHINE_CODE EM_SH
#ifdef __QNXTARGET__
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 12
-#ifndef INCLUDE_SHMEDIA
+#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
#include "elf32-target.h"
#include "elf32-target.h"
-#endif /* INCLUDE_SHMEDIA */
+#endif /* neither INCLUDE_SHMEDIA nor SH_TARGET_ALREADY_DEFINED */