mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
6d00b59031
This renames the bfd targets to <cpu>_<format>_<other>_<endian>_vec. So for example, bfd_elf32_ntradlittlemips_vec becomes mips_elf32_ntrad_le_vec and hp300bsd_vec becomes m68k_aout_hp300bsd_vec. bfd/ * aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-ns32k.c, * aout-sparcle.c, * aout0.c, * aoutx.h, * armnetbsd.c, * bout.c, * cf-i386lynx.c, * cf-sparclynx.c, * cisco-core.c, * coff-alpha.c, * coff-apollo.c, * coff-arm.c, * coff-aux.c, * coff-go32.c, * coff-h8300.c, * coff-h8500.c, * coff-i386.c, * coff-i860.c, * coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mips.c, * coff-rs6000.c, * coff-sh.c, * coff-sparc.c, * coff-stgo32.c, * coff-svm68k.c, * coff-tic80.c, * coff-u68k.c, * coff-w65.c, * coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c, * coff64-rs6000.c, * config.bfd, * configure.com, * configure.in, * demo64.c, * elf-m10200.c, * elf-m10300.c, * elf32-am33lin.c, * elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-gen.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i370.c, * elf32-i386.c, * elf32-i860.c, * elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-sh-symbian.c, * elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c, * elf64-gen.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c, * elf64-x86-64.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c, * epoc-pe-arm.c, * epoc-pei-arm.c, * hp300bsd.c, * hp300hpux.c, * hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386bsd.c, * i386dynix.c, * i386freebsd.c, * i386linux.c, * i386lynx.c, * i386mach3.c, * i386msdos.c, * i386netbsd.c, * i386os9k.c, * irix-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c, * m88kmach3.c, * m88kopenbsd.c, * mach-o-i386.c, * mach-o-x86-64.c, * makefile.vms, * mipsbsd.c, * mmo.c, * netbsd-core.c, * newsos3.c, * nlm32-alpha.c, * nlm32-i386.c, * nlm32-ppc.c, * nlm32-sparc.c, * ns32knetbsd.c, * osf-core.c, * pc532-mach.c, * pe-arm-wince.c, * pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-ppc.c, * pe-sh.c, * pe-x86_64.c, * pei-arm-wince.c, * pei-arm.c, * pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-mips.c, * pei-ppc.c, * pei-sh.c, * pei-x86_64.c, * ppcboot.c, * ptrace-core.c, * riscix.c, * sco5-core.c, * som.c, * sparclinux.c, * sparclynx.c, * sparcnetbsd.c, * sunos.c, * targets.c, * trad-core.c, * vax1knetbsd.c, * vaxbsd.c, * vaxnetbsd.c, * versados.c, * vms-alpha.c, * vms-lib.c: Rename bfd targets to <cpu>_<format>_<other>_<endian>_vec. Adjust associated MY macros on aout targets. * configure: Regenerate. binutils/ * emul_aix.c: Update bfd target vector naming. * testsuite/binutils-all/objcopy.exp: Likewise. ld/ * emultempl/metagelf.em: Update bfd target vector naming. * emultempl/nios2elf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/tic6xdsbt.em: Likewise.
209 lines
8.4 KiB
C
209 lines
8.4 KiB
C
/* BFD back-end for Sparc COFF files.
|
|
Copyright (C) 1990-2014 Free Software Foundation, Inc.
|
|
Written by Cygnus Support.
|
|
|
|
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 "coff/sparc.h"
|
|
#include "coff/internal.h"
|
|
#include "libcoff.h"
|
|
|
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
|
|
|
#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
|
|
|
|
/* The page size is a guess based on ELF. */
|
|
#define COFF_PAGE_SIZE 0x10000
|
|
|
|
enum reloc_type
|
|
{
|
|
R_SPARC_NONE = 0,
|
|
R_SPARC_8, R_SPARC_16, R_SPARC_32,
|
|
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
|
|
R_SPARC_WDISP30, R_SPARC_WDISP22,
|
|
R_SPARC_HI22, R_SPARC_22,
|
|
R_SPARC_13, R_SPARC_LO10,
|
|
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
|
|
R_SPARC_PC10, R_SPARC_PC22,
|
|
R_SPARC_WPLT30,
|
|
R_SPARC_COPY,
|
|
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
|
|
R_SPARC_RELATIVE,
|
|
R_SPARC_UA32,
|
|
R_SPARC_max
|
|
};
|
|
|
|
/* This is stolen pretty directly from elf.c. */
|
|
|
|
static bfd_reloc_status_type
|
|
bfd_coff_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
|
|
arelent *reloc_entry,
|
|
asymbol *symbol,
|
|
void * data ATTRIBUTE_UNUSED,
|
|
asection *input_section,
|
|
bfd *output_bfd,
|
|
char **error_message ATTRIBUTE_UNUSED)
|
|
{
|
|
if (output_bfd != (bfd *) NULL
|
|
&& (symbol->flags & BSF_SECTION_SYM) == 0)
|
|
{
|
|
reloc_entry->address += input_section->output_offset;
|
|
return bfd_reloc_ok;
|
|
}
|
|
|
|
return bfd_reloc_continue;
|
|
}
|
|
|
|
static reloc_howto_type coff_sparc_howto_table[] =
|
|
{
|
|
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_8, 0,0, 8,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", FALSE,0,0x000000ff,TRUE),
|
|
HOWTO(R_SPARC_16, 0,1,16,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", FALSE,0,0x0000ffff,TRUE),
|
|
HOWTO(R_SPARC_32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", FALSE,0,0xffffffff,TRUE),
|
|
HOWTO(R_SPARC_DISP8, 0,0, 8,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", FALSE,0,0x000000ff,TRUE),
|
|
HOWTO(R_SPARC_DISP16, 0,1,16,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", FALSE,0,0x0000ffff,TRUE),
|
|
HOWTO(R_SPARC_DISP32, 0,2,32,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", FALSE,0,0x00ffffff,TRUE),
|
|
HOWTO(R_SPARC_WDISP30, 2,2,30,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", FALSE,0,0x3fffffff,TRUE),
|
|
HOWTO(R_SPARC_WDISP22, 2,2,22,TRUE, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", FALSE,0,0x003fffff,TRUE),
|
|
HOWTO(R_SPARC_HI22, 10,2,22,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", FALSE,0,0x003fffff,TRUE),
|
|
HOWTO(R_SPARC_22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", FALSE,0,0x003fffff,TRUE),
|
|
HOWTO(R_SPARC_13, 0,2,13,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", FALSE,0,0x00001fff,TRUE),
|
|
HOWTO(R_SPARC_LO10, 0,2,10,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", FALSE,0,0x000003ff,TRUE),
|
|
HOWTO(R_SPARC_GOT10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", FALSE,0,0x000003ff,TRUE),
|
|
HOWTO(R_SPARC_GOT13, 0,2,13,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", FALSE,0,0x00001fff,TRUE),
|
|
HOWTO(R_SPARC_GOT22, 10,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", FALSE,0,0x003fffff,TRUE),
|
|
HOWTO(R_SPARC_PC10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", FALSE,0,0x000003ff,TRUE),
|
|
HOWTO(R_SPARC_PC22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", FALSE,0,0x003fffff,TRUE),
|
|
HOWTO(R_SPARC_WPLT30, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_GLOB_DAT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_JMP_SLOT,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_RELATIVE,0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE),
|
|
HOWTO(R_SPARC_UA32, 0,0,00,FALSE,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", FALSE,0,0x00000000,TRUE),
|
|
};
|
|
|
|
struct coff_reloc_map
|
|
{
|
|
bfd_reloc_code_real_type bfd_reloc_val;
|
|
unsigned char coff_reloc_val;
|
|
};
|
|
|
|
static const struct coff_reloc_map sparc_reloc_map[] =
|
|
{
|
|
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
|
{ BFD_RELOC_16, R_SPARC_16, },
|
|
{ BFD_RELOC_8, R_SPARC_8 },
|
|
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
|
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
|
{ BFD_RELOC_32, R_SPARC_32 },
|
|
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
|
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
|
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
|
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
|
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
|
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
|
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
|
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
|
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
|
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
|
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
|
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
|
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
|
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
|
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
|
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
|
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
|
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
|
};
|
|
|
|
static reloc_howto_type *
|
|
coff_sparc_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
bfd_reloc_code_real_type code)
|
|
{
|
|
unsigned int i;
|
|
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
|
|
{
|
|
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
|
return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
|
|
}
|
|
return 0;
|
|
}
|
|
#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
|
|
|
|
static reloc_howto_type *
|
|
coff_sparc_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
const char *r_name)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 0;
|
|
i < (sizeof (coff_sparc_howto_table)
|
|
/ sizeof (coff_sparc_howto_table[0]));
|
|
i++)
|
|
if (coff_sparc_howto_table[i].name != NULL
|
|
&& strcasecmp (coff_sparc_howto_table[i].name, r_name) == 0)
|
|
return &coff_sparc_howto_table[i];
|
|
|
|
return NULL;
|
|
}
|
|
#define coff_bfd_reloc_name_lookup coff_sparc_reloc_name_lookup
|
|
|
|
static void
|
|
rtype2howto (arelent *cache_ptr, struct internal_reloc *dst)
|
|
{
|
|
BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
|
|
cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
|
|
}
|
|
|
|
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
|
|
|
#define SWAP_IN_RELOC_OFFSET H_GET_32
|
|
#define SWAP_OUT_RELOC_OFFSET H_PUT_32
|
|
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
|
cache_ptr->addend = reloc.r_offset;
|
|
|
|
/* Clear the r_spare field in relocs. */
|
|
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
|
do { \
|
|
dst->r_spare[0] = 0; \
|
|
dst->r_spare[1] = 0; \
|
|
} while (0)
|
|
|
|
#define __A_MAGIC_SET__
|
|
|
|
/* Enable Sparc-specific hacks in coffcode.h. */
|
|
|
|
#define COFF_SPARC
|
|
|
|
#define bfd_pe_print_pdata NULL
|
|
|
|
#include "coffcode.h"
|
|
|
|
#ifndef TARGET_SYM
|
|
#define TARGET_SYM sparc_coff_vec
|
|
#endif
|
|
|
|
#ifndef TARGET_NAME
|
|
#define TARGET_NAME "coff-sparc"
|
|
#endif
|
|
|
|
CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL, COFF_SWAP_TABLE)
|