X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-sh.c;h=567ef249f711a4b8e30110d382728ec8580c8cdd;hb=8dbe7ca5a5755274fca1d3021ad648a1575e66cb;hp=34dfea2197e58fcdec2558e4b085b55b98d65ba6;hpb=c72f2fb2bb6a3e1850b081dbfce4040970fae8e6;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 34dfea2197..567ef249f7 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -1,5 +1,5 @@ /* 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. @@ -255,6 +255,11 @@ sh_elf_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol_in, && 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 @@ -474,13 +479,19 @@ sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) 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; } @@ -702,10 +713,10 @@ sh_elf_relax_section (bfd *abfd, asection *sec, 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, @@ -716,7 +727,10 @@ sh_elf_relax_section (bfd *abfd, asection *sec, /* 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; @@ -2916,7 +2930,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, 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 @@ -3676,7 +3690,9 @@ sh_elf_osec_to_segment (bfd *output_bfd, asection *osec) { 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