mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
6346d5ca43
Commitec93045b
andcd21f5da
introduced a large number of tic4x and tic54x regressions, due to the new checks being wrong for targets with octets_per_byte != 1. To fix that I introduced a new bfd_get_section_limit_octets and performed the check on octets rather than byte adresses, reducing the number of bfd_octets_per_byte calls. bfd_octets_per_byte is rather expensive.. I then wondered why the same bfd_reloc_outofrange check added to bfd_perform_relocation wasn't also added to bfd_install_relocation. The two functions are virtually identical and ought to remain that way. However, adding the same check to bfd_install_relocation resulted in ld-elf "FAIL Link eh-group.o to eh-group" on many ELF targets, including x64_64-linux. The reason being that eh-group.o has NONE relocs at the end of a section, and most targets give NONE relocs a non-zero size. So if we are to keep the new outofrange check it appears that NONE relocs must have a zero size. * bfd-in.h (bfd_get_section_limit_octets): New define, extracted from.. (bfd_get_section_limit): ..here. * reloc.c (bfd_perform_relocation): Correct bfd_reloc_outofrange check. (bfd_install_relocation, _bfd_final_link_relocate): Add same check here. * elf32-sh.c (sh_elf_reloc): Correct bfd_reloc_outofrange check. * elf32-ppc.c (ppc_elf_addr16_ha_reloc): Remove duplicated bfd_reloc_outofrange check. * bfd-in2.h: Regenerate. * cpu-ns32k.c (_bfd_do_ns32k_reloc_contents): Return bfd_reloc_ok on zero size relocs. * ecoff.c (ecoff_reloc_link_order): Likewise. * elf32-nds32.c (nds32_relocate_contents): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise. * reloc.c (_bfd_relocate_contents): Don't bomb on zero size relocs. (_bfd_clear_contents): Likewise. * elfxx-mips.c (mips_elf_obtain_contents): Likewise. (mips_elf_perform_relocation): Likewise. * aoutx.h (aout_link_reloc_link_order): Allow for NULL return from malloc on zero size alloc. * cofflink.c (_bfd_coff_reloc_link_order): Likewise. * elflink.c (elf_reloc_link_order): Likewise. * linker.c (_bfd_generic_reloc_link_order): Likewise. * pdp11.c (aout_link_reloc_link_order): Likewise. * xcofflink.c (xcoff_reloc_link_order): Likewise. * aoutx.h (howto_table_ext): Ensure NONE relocs have size 3, bitsize 0, and complain_overflow_dont. * coff-sparc.c (coff_sparc_howto_table): Likewise. * elf-hppa.h (elf_hppa_howto_table): Likewise. * elf-m10200.c (elf_mn10200_howto_table): Likewise. * elf-m10300.c (elf_mn10300_howto_table): Likewise. * elf32-arc.c (elf_arc_howto_table): Likewise. * elf32-arm.c (elf32_arm_howto_table_1): Likewise. * elf32-avr.c (elf_avr_howto_table): Likewise. * elf32-bfin.c (bfin_howto_table): Likewise. * elf32-cr16.c (cr16_elf_howto_table): Likewise. * elf32-cris.c (cris_elf_howto_table): Likewise. * elf32-crx.c (crx_elf_howto_table): Likewise. * elf32-d10v.c (elf_d10v_howto_table): Likewise. * elf32-d30v.c (elf_d30v_howto_table): Likewise. * elf32-dlx.c (dlx_elf_howto_table): Likewise. * elf32-epiphany.c (epiphany_elf_howto_table): Likewise. * elf32-fr30.c (fr30_elf_howto_table): Likewise. * elf32-frv.c (elf32_frv_howto_table): Likewise. * elf32-h8300.c (h8_elf_howto_table): Likewise. * elf32-i370.c (i370_elf_howto_raw): Likewise. * elf32-i386.c (elf_howto_table): Likewise. * elf32-i860.c (elf32_i860_howto_table): Likewise. * elf32-i960.c (elf32_i960_relocate): Likewise. * elf32-ip2k.c (ip2k_elf_howto_table): Likewise. * elf32-iq2000.c (iq2000_elf_howto_table): Likewise. * elf32-lm32.c (lm32_elf_howto_table): Likewise. * elf32-m32c.c (m32c_elf_howto_table): Likewise. * elf32-m32r.c (m32r_elf_howto_table): Likewise. * elf32-m68hc11.c (elf_m68hc11_howto_table): Likewise. * elf32-m68hc12.c (elf_m68hc11_howto_table): Likewise. * elf32-m68k.c (howto_table): Likewise. * elf32-mcore.c (mcore_elf_howto_raw): Likewise. * elf32-mep.c (mep_elf_howto_table): Likewise. * elf32-metag.c (elf_metag_howto_table): Likewise. * elf32-microblaze.c (microblaze_elf_howto_raw): Likewise. * elf32-mips.c (elf_mips_howto_table_rel): Likewise. * elf32-moxie.c (moxie_elf_howto_table): Likewise. * elf32-msp430.c (elf_msp430_howto_table): Likewise. * elf32-mt.c (mt_elf_howto_table): Likewise. * elf32-nds32.c (nds32_elf_howto_table): Likewise. * elf32-nios2.c (elf_nios2_howto_table_rel): Likewise. * elf32-or1k.c (or1k_elf_howto_table): Likewise. * elf32-pj.c (pj_elf_howto_table): Likewise. * elf32-ppc.c (ppc_elf_howto_raw): Likewise. * elf32-rl78.c (rl78_elf_howto_table): Likewise. * elf32-rx.c (rx_elf_howto_table): Likewise. * elf32-s390.c (elf_howto_table): Likewise. * elf32-score.c (elf32_score_howto_table): Likewise. * elf32-score7.c (elf32_score_howto_table): Likewise. * elf32-sh-relocs.h (R_SH_NONE): Likewise. * elf32-spu.c (elf_howto_table): Likewise. * elf32-tic6x.c (elf32_tic6x_howto_table): Likewise. * elf32-tilepro.c (tilepro_elf_howto_table): Likewise. * elf32-v850.c (v850_elf_howto_table): Likewise. * elf32-vax.c (howto_table): Likewise. * elf32-visium.c (visium_elf_howto_table): Likewise. * elf32-xc16x.c (xc16x_elf_howto_table): Likewise. * elf32-xgate.c (elf_xgate_howto_table): Likewise. * elf32-xstormy16.c (xstormy16_elf_howto_table): Likewise. * elf32-xtensa.c (elf_howto_table): Likewise. * elf64-alpha.c (elf64_alpha_howto_table): Likewise. * elf64-mips.c (mips_elf64_howto_table_rel): Likewise. * elf64-mmix.c (elf_mmix_howto_table): Likewise. * elf64-ppc.c (ppc64_elf_howto_raw): Likewise. * elf64-s390.c (elf_howto_table): Likewise. * elf64-sh64.c (sh_elf64_howto_table): Likewise. * elf64-x86-64.c (x86_64_elf_howto_table): Likewise. * elfn32-mips.c (elf_mips_howto_table_rel): Likewise. * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise. (elfNN_aarch64_howto_none): Likewise. * elfxx-ia64.c (ia64_howto_table): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_howto_table): Likewise. * elfxx-tilegx.c (tilegx_elf_howto_table): Likewise. * nlm32-sparc.c (nlm32_sparc_howto_table): Likewise.
174 lines
5.3 KiB
C
174 lines
5.3 KiB
C
/* Intel 960 specific support for 32-bit ELF
|
|
Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
#include "sysdep.h"
|
|
#include "bfd.h"
|
|
#include "libbfd.h"
|
|
#include "elf-bfd.h"
|
|
#include "elf/i960.h"
|
|
|
|
#define USE_REL 1
|
|
|
|
#define bfd_elf32_bfd_reloc_type_lookup elf32_i960_reloc_type_lookup
|
|
#define bfd_elf32_bfd_reloc_name_lookup \
|
|
elf32_i960_reloc_name_lookup
|
|
#define elf_info_to_howto elf32_i960_info_to_howto
|
|
#define elf_info_to_howto_rel elf32_i960_info_to_howto_rel
|
|
|
|
/* ELF relocs are against symbols. If we are producing relocatable
|
|
output, and the reloc is against an external symbol, and nothing
|
|
has given us any additional addend, the resulting reloc will also
|
|
be against the same symbol. In such a case, we don't want to
|
|
change anything about the way the reloc is handled, since it will
|
|
all be done at final link time. Rather than put special case code
|
|
into bfd_perform_relocation, all the reloc types use this howto
|
|
function. It just short circuits the reloc if producing
|
|
relocatable output against an external symbol. */
|
|
|
|
static bfd_reloc_status_type
|
|
elf32_i960_relocate (bfd *abfd ATTRIBUTE_UNUSED,
|
|
arelent *reloc_entry,
|
|
asymbol *symbol,
|
|
void * data ATTRIBUTE_UNUSED,
|
|
asection *input_section,
|
|
bfd *output_bfd,
|
|
char **error_message ATTRIBUTE_UNUSED)
|
|
{
|
|
/* HACK: I think this first condition is necessary when producing
|
|
relocatable output. After the end of HACK, the code is identical
|
|
to bfd_elf_generic_reloc(). I would _guess_ the first change
|
|
belongs there rather than here. martindo 1998-10-23. */
|
|
if (output_bfd != (bfd *) NULL
|
|
&& reloc_entry->howto->pc_relative
|
|
&& !reloc_entry->howto->pcrel_offset)
|
|
reloc_entry->addend -= symbol->value;
|
|
|
|
/* This is more dubious. */
|
|
else if (output_bfd != (bfd *) NULL
|
|
&& (symbol->flags & BSF_SECTION_SYM) != 0)
|
|
reloc_entry->addend -= symbol->section->output_section->vma;
|
|
|
|
else
|
|
{
|
|
/* ...end of HACK. */
|
|
if (output_bfd != (bfd *) NULL
|
|
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
|
&& (! reloc_entry->howto->partial_inplace
|
|
|| reloc_entry->addend == 0))
|
|
{
|
|
reloc_entry->address += input_section->output_offset;
|
|
return bfd_reloc_ok;
|
|
}
|
|
}
|
|
|
|
return bfd_reloc_continue;
|
|
}
|
|
|
|
static reloc_howto_type elf_howto_table[]=
|
|
{
|
|
HOWTO (R_960_NONE, 0, 3, 0, FALSE, 0, complain_overflow_dont,
|
|
elf32_i960_relocate, "R_960_NONE", TRUE,
|
|
0x00000000, 0x00000000, FALSE),
|
|
EMPTY_HOWTO (1),
|
|
HOWTO (R_960_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
|
|
elf32_i960_relocate, "R_960_32", TRUE,
|
|
0xffffffff, 0xffffffff, FALSE),
|
|
HOWTO (R_960_IP24, 0, 2, 24, TRUE, 0, complain_overflow_signed,
|
|
elf32_i960_relocate, "R_960_IP24 ", TRUE,
|
|
0x00ffffff, 0x00ffffff, FALSE),
|
|
EMPTY_HOWTO (4),
|
|
EMPTY_HOWTO (5),
|
|
EMPTY_HOWTO (6),
|
|
EMPTY_HOWTO (7)
|
|
};
|
|
|
|
static enum elf_i960_reloc_type
|
|
elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code)
|
|
{
|
|
switch (code)
|
|
{
|
|
default:
|
|
return R_960_NONE;
|
|
case BFD_RELOC_I960_CALLJ:
|
|
return R_960_OPTCALL;
|
|
case BFD_RELOC_32:
|
|
case BFD_RELOC_CTOR:
|
|
return R_960_32;
|
|
case BFD_RELOC_24_PCREL:
|
|
return R_960_IP24;
|
|
}
|
|
}
|
|
|
|
static void
|
|
elf32_i960_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
|
|
arelent * cache_ptr ATTRIBUTE_UNUSED,
|
|
Elf_Internal_Rela * dst ATTRIBUTE_UNUSED)
|
|
{
|
|
abort ();
|
|
}
|
|
|
|
static void
|
|
elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
|
|
arelent *cache_ptr,
|
|
Elf_Internal_Rela *dst)
|
|
{
|
|
enum elf_i960_reloc_type type;
|
|
|
|
type = (enum elf_i960_reloc_type) ELF32_R_TYPE (dst->r_info);
|
|
|
|
/* PR 17521: file: 9609b8d6. */
|
|
if (type >= R_960_max)
|
|
{
|
|
_bfd_error_handler (_("%A; invalid i960 reloc number: %d"), abfd, type);
|
|
type = 0;
|
|
}
|
|
|
|
cache_ptr->howto = &elf_howto_table[(int) type];
|
|
}
|
|
|
|
static reloc_howto_type *
|
|
elf32_i960_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
bfd_reloc_code_real_type code)
|
|
{
|
|
return elf_howto_table + elf32_i960_bfd_to_reloc_type (code);
|
|
}
|
|
|
|
static reloc_howto_type *
|
|
elf32_i960_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
const char *r_name)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < sizeof (elf_howto_table) / sizeof (elf_howto_table[0]); i++)
|
|
if (elf_howto_table[i].name != NULL
|
|
&& strcasecmp (elf_howto_table[i].name, r_name) == 0)
|
|
return &elf_howto_table[i];
|
|
|
|
return NULL;
|
|
}
|
|
|
|
#define TARGET_LITTLE_SYM i960_elf32_vec
|
|
#define TARGET_LITTLE_NAME "elf32-i960"
|
|
#define ELF_ARCH bfd_arch_i960
|
|
#define ELF_MACHINE_CODE EM_960
|
|
#define ELF_MAXPAGESIZE 1 /* FIXME: This number is wrong, It should be the page size in bytes. */
|
|
|
|
#include "elf32-target.h"
|