/* Renesas / SuperH SH specific support for 32-bit ELF
- Copyright (C) 1996-2014 Free Software Foundation, Inc.
+ Copyright (C) 1996-2015 Free Software Foundation, Inc.
Contributed by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
vxworks_object_p (bfd *abfd ATTRIBUTE_UNUSED)
{
#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
- extern const bfd_target bfd_elf32_shlvxworks_vec;
- extern const bfd_target bfd_elf32_shvxworks_vec;
+ extern const bfd_target sh_elf32_vxworks_le_vec;
+ extern const bfd_target sh_elf32_vxworks_vec;
- return (abfd->xvec == &bfd_elf32_shlvxworks_vec
- || abfd->xvec == &bfd_elf32_shvxworks_vec);
+ return (abfd->xvec == &sh_elf32_vxworks_le_vec
+ || abfd->xvec == &sh_elf32_vxworks_vec);
#else
return FALSE;
#endif
fdpic_object_p (bfd *abfd ATTRIBUTE_UNUSED)
{
#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
- extern const bfd_target bfd_elf32_shfd_vec;
- extern const bfd_target bfd_elf32_shbfd_vec;
+ extern const bfd_target sh_elf32_fdpic_le_vec;
+ extern const bfd_target sh_elf32_fdpic_be_vec;
- return (abfd->xvec == &bfd_elf32_shfd_vec
- || abfd->xvec == &bfd_elf32_shbfd_vec);
+ return (abfd->xvec == &sh_elf32_fdpic_le_vec
+ || abfd->xvec == &sh_elf32_fdpic_be_vec);
#else
return FALSE;
#endif
&& bfd_is_und_section (symbol_in->section))
return bfd_reloc_undefined;
+ /* PR 17512: file: 9891ca98. */
+ if (addr * bfd_octets_per_byte (abfd) + bfd_get_reloc_size (reloc_entry->howto)
+ > bfd_get_section_limit_octets (abfd, input_section))
+ return bfd_reloc_outofrange;
+
if (bfd_is_com_section (symbol_in->section))
sym_value = 0;
else
r = ELF32_R_TYPE (dst->r_info);
- BFD_ASSERT (r < (unsigned int) R_SH_max);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC || r > R_SH_LAST_INVALID_RELOC);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_2 || r > R_SH_LAST_INVALID_RELOC_2);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_3 || r > R_SH_LAST_INVALID_RELOC_3);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_4 || r > R_SH_LAST_INVALID_RELOC_4);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_5 || r > R_SH_LAST_INVALID_RELOC_5);
- BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_6 || r > R_SH_LAST_INVALID_RELOC_6);
+ if (r >= R_SH_max
+ || (r >= R_SH_FIRST_INVALID_RELOC && r <= R_SH_LAST_INVALID_RELOC)
+ || (r >= R_SH_FIRST_INVALID_RELOC_2 && r <= R_SH_LAST_INVALID_RELOC_2)
+ || (r >= R_SH_FIRST_INVALID_RELOC_3 && r <= R_SH_LAST_INVALID_RELOC_3)
+ || (r >= R_SH_FIRST_INVALID_RELOC_4 && r <= R_SH_LAST_INVALID_RELOC_4)
+ || (r >= R_SH_FIRST_INVALID_RELOC_5 && r <= R_SH_LAST_INVALID_RELOC_5)
+ || (r >= R_SH_FIRST_INVALID_RELOC_6 && r <= R_SH_LAST_INVALID_RELOC_6))
+ {
+ (*_bfd_error_handler) (_("%B: unrecognised SH reloc number: %d"),
+ abfd, r);
+ bfd_set_error (bfd_error_bad_value);
+ r = R_SH_NONE;
+ }
cache_ptr->howto = get_howto_table (abfd) + r;
}
elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Replace the jsr with a bsr. */
+ /* Replace the jmp/jsr with a bra/bsr. */
/* Change the R_SH_USES reloc into an R_SH_IND12W reloc, and
- replace the jsr with a bsr. */
+ replace the jmp/jsr with a bra/bsr. */
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_SH_IND12W);
/* We used to test (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
here, but that only checks if the symbol is an external symbol,
/* We can't fully resolve this yet, because the external
symbol value may be changed by future relaxing. We let
the final link phase handle it. */
- bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
+ if (bfd_get_16 (abfd, contents + irel->r_offset) & 0x0020)
+ bfd_put_16 (abfd, (bfd_vma) 0xa000, contents + irel->r_offset);
+ else
+ bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
irel->r_addend = -4;
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
/* 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;
{
Elf_Internal_Phdr *p = NULL;
- if (output_bfd->xvec->flavour == bfd_target_elf_flavour)
+ if (output_bfd->xvec->flavour == bfd_target_elf_flavour
+ /* PR ld/17110: Do not look for output segments in an input bfd. */
+ && output_bfd->direction != read_direction)
p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
/* FIXME: Nothing ever says what this index is relative to. The kernel
}
#if !defined SH_TARGET_ALREADY_DEFINED
-#define TARGET_BIG_SYM bfd_elf32_sh_vec
+#define TARGET_BIG_SYM sh_elf32_vec
#define TARGET_BIG_NAME "elf32-sh"
-#define TARGET_LITTLE_SYM bfd_elf32_shl_vec
+#define TARGET_LITTLE_SYM sh_elf32_le_vec
#define TARGET_LITTLE_NAME "elf32-shl"
#endif
/* NetBSD support. */
#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_shnbsd_vec
+#define TARGET_BIG_SYM sh_elf32_nbsd_vec
#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf32-sh-nbsd"
#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_shlnbsd_vec
+#define TARGET_LITTLE_SYM sh_elf32_nbsd_le_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-shl-nbsd"
#undef ELF_MAXPAGESIZE
/* Linux support. */
#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_shblin_vec
+#define TARGET_BIG_SYM sh_elf32_linux_be_vec
#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf32-shbig-linux"
#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_shlin_vec
+#define TARGET_LITTLE_SYM sh_elf32_linux_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-sh-linux"
#undef ELF_COMMONPAGESIZE
/* FDPIC support. */
#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_shbfd_vec
+#define TARGET_BIG_SYM sh_elf32_fdpic_be_vec
#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf32-shbig-fdpic"
#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_shfd_vec
+#define TARGET_LITTLE_SYM sh_elf32_fdpic_le_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-sh-fdpic"
/* VxWorks support. */
#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM bfd_elf32_shvxworks_vec
+#define TARGET_BIG_SYM sh_elf32_vxworks_vec
#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf32-sh-vxworks"
#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM bfd_elf32_shlvxworks_vec
+#define TARGET_LITTLE_SYM sh_elf32_vxworks_le_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-shl-vxworks"
#undef elf32_bed