X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoff-sparc.c;h=35c23df521f6f83adf502a992d9c452d4b162da2;hb=41ae02c9eaedd88a26c7772a54e50a03ee129f7c;hp=e1c3f3d2f80a52bd654958230ffeaf23fd5404ff;hpb=1a000744e69640482b0dea4f153fcee77305ff5f;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coff-sparc.c b/bfd/coff-sparc.c index e1c3f3d2f8..35c23df521 100644 --- a/bfd/coff-sparc.c +++ b/bfd/coff-sparc.c @@ -1,5 +1,6 @@ /* BFD back-end for Sparc COFF files. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -16,23 +17,32 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/sparc.h" #include "coff/internal.h" #include "libcoff.h" -#define BADMAG(x) ((x).f_magic != SPARCMAGIC) +#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 + + +static reloc_howto_type *coff_sparc_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); +static void rtype2howto PARAMS ((arelent *, struct internal_reloc *)); 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_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, @@ -47,7 +57,7 @@ enum reloc_type }; #if 0 -static CONST char *CONST reloc_type_names[] = +static const char *const reloc_type_names[] = { "R_SPARC_NONE", "R_SPARC_8", "R_SPARC_16", "R_SPARC_32", @@ -73,17 +83,16 @@ bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, static bfd_reloc_status_type bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; arelent *reloc_entry; asymbol *symbol; - PTR data; + PTR data ATTRIBUTE_UNUSED; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { if (output_bfd != (bfd *) NULL - && (symbol->flags & BSF_SECTION_SYM) == 0 - && reloc_entry->addend == 0) + && (symbol->flags & BSF_SECTION_SYM) == 0) { reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; @@ -92,7 +101,7 @@ bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section, return bfd_reloc_continue; } -static reloc_howto_type coff_sparc_howto_table[] = +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), @@ -121,11 +130,11 @@ static reloc_howto_type coff_sparc_howto_table[] = }; struct coff_reloc_map { - unsigned char bfd_reloc_val; + bfd_reloc_code_real_type bfd_reloc_val; unsigned char coff_reloc_val; }; -static CONST struct coff_reloc_map sparc_reloc_map[] = +static const struct coff_reloc_map sparc_reloc_map[] = { { BFD_RELOC_NONE, R_SPARC_NONE, }, { BFD_RELOC_16, R_SPARC_16, }, @@ -153,12 +162,12 @@ static CONST struct coff_reloc_map sparc_reloc_map[] = /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */ }; -static CONST struct reloc_howto_struct * +static reloc_howto_type * coff_sparc_reloc_type_lookup (abfd, code) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; bfd_reloc_code_real_type code; { - int i; + 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) @@ -179,84 +188,32 @@ rtype2howto (cache_ptr, dst) #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) -#define SWAP_IN_RELOC_OFFSET bfd_h_get_32 -#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32 -/* This is just like the standard one, except for the addition of the - last line, the adjustment of the addend. */ -#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ - { \ - coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \ - if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ - coffsym = (obj_symbols (abfd) \ - + (cache_ptr->sym_ptr_ptr - symbols)); \ - else if (ptr) \ - coffsym = coff_symbol_from (abfd, ptr); \ - if (coffsym != (coff_symbol_type *) NULL \ - && coffsym->native->u.syment.n_scnum == 0) \ - cache_ptr->addend = 0; \ - else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ - && ptr->section != (asection *) NULL) \ - cache_ptr->addend = - (ptr->section->vma + ptr->value); \ - else \ - cache_ptr->addend = 0; \ - cache_ptr->addend += reloc.r_offset; \ - } - -#define __A_MAGIC_SET__ - -#include "coffcode.h" +#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; -bfd_target -#ifdef TARGET_SYM - TARGET_SYM = -#else - sparccoff_vec = -#endif -{ -#ifdef TARGET_NAME - TARGET_NAME, -#else - "coff-sparc", /* name */ -#endif - bfd_target_coff_flavour, - true, /* data byte order is big */ - true, /* header byte order is big */ +/* 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) - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), +#define __A_MAGIC_SET__ - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - 0, /* leading underscore */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ +/* Enable Sparc-specific hacks in coffcode.h. */ - 3, /* minimum alignment power */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ - bfd_getb64, bfd_getb_signed_64, bfd_putb64, - bfd_getb32, bfd_getb_signed_32, bfd_putb32, - bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ +#define COFF_SPARC -/* Note that we allow an object file to be treated as a core file as well. */ - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, coff_object_p}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, +#include "coffcode.h" - BFD_JUMP_TABLE_GENERIC (coff), - BFD_JUMP_TABLE_COPY (coff), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), - BFD_JUMP_TABLE_SYMBOLS (coff), - BFD_JUMP_TABLE_RELOCS (coff), - BFD_JUMP_TABLE_WRITE (coff), - BFD_JUMP_TABLE_LINK (coff), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), +#ifndef TARGET_SYM +#define TARGET_SYM sparccoff_vec +#endif - COFF_SWAP_TABLE, -}; +#ifndef TARGET_NAME +#define TARGET_NAME "coff-sparc" +#endif +CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, D_PAGED, 0, '_', NULL)