From: Ian Lance Taylor Date: Thu, 4 Mar 1993 22:48:46 +0000 (+0000) Subject: * coff-mips.c (ecoff_bfd_reloc_type_lookup): New function. X-Git-Tag: gdb-4_18~19971 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f68d8549cc14827a2adbfeefbcf05daad2895e79;p=platform%2Fupstream%2Fbinutils.git * coff-mips.c (ecoff_bfd_reloc_type_lookup): New function. (ecoff_write_object_contents): Added BFD_ASSERT calls to ensure relocs are reasonable. * coff-msym.c: Eliminated uses of DEFUN. (ecoff_swap_tir_out): New function. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 88cd1d1..fa96099 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +Thu Mar 4 14:44:01 1993 Ian Lance Taylor (ian@cygnus.com) + + * coff-mips.c (ecoff_bfd_reloc_type_lookup): New function. + (ecoff_write_object_contents): Added BFD_ASSERT calls to ensure + relocs are reasonable. + * coff-msym.c: Eliminated uses of DEFUN. + (ecoff_swap_tir_out): New function. + Tue Mar 2 17:52:58 1993 Fred Fish (fnf@cygnus.com) (Ultrix 2.2 support from Michael Rendell ) diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index c5b3946..595c19b 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -134,6 +134,8 @@ static unsigned int ecoff_canonicalize_reloc PARAMS ((bfd *abfd, asection *section, arelent **relptr, asymbol **symbols)); +static CONST struct reloc_howto_struct *ecoff_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); static boolean ecoff_find_nearest_line PARAMS ((bfd *abfd, asection *section, asymbol **symbols, @@ -1862,6 +1864,9 @@ static reloc_howto_type ecoff_howto_table[] = false) /* pcrel_offset */ }; +#define ECOFF_HOWTO_COUNT \ + (sizeof ecoff_howto_table / sizeof ecoff_howto_table[0]) + /* Read in the relocs for a section. */ static boolean @@ -2009,6 +2014,39 @@ ecoff_canonicalize_reloc (abfd, section, relptr, symbols) return section->reloc_count; } + +/* Get the howto structure for a generic reloc type. */ + +static CONST struct reloc_howto_struct * +ecoff_bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; +{ + int ecoff_type; + + switch (code) + { + case BFD_RELOC_16: + ecoff_type = ECOFF_R_REFHALF; + break; + case BFD_RELOC_32: + ecoff_type = ECOFF_R_REFWORD; + break; + case BFD_RELOC_MIPS_JMP: + ecoff_type = ECOFF_R_JMPADDR; + break; + case BFD_RELOC_HI16_S: + ecoff_type = ECOFF_R_REFHI; + break; + case BFD_RELOC_LO16: + ecoff_type = ECOFF_R_REFLO; + break; + default: + return (CONST struct reloc_howto_struct *) NULL; + } + + return &ecoff_howto_table[ecoff_type]; +} /* Provided a BFD, a section and an offset into the section, calculate and return the name of the source file and the line nearest to the @@ -3425,8 +3463,25 @@ ecoff_write_object_contents (abfd) reloc = *reloc_ptr_ptr; sym = *reloc->sym_ptr_ptr; + /* This must be an ECOFF reloc. */ + BFD_ASSERT (reloc->howto != (reloc_howto_type *) NULL + && reloc->howto >= ecoff_howto_table + && (reloc->howto + < (ecoff_howto_table + ECOFF_HOWTO_COUNT))); + in.r_vaddr = reloc->address + bfd_get_section_vma (abfd, current); in.r_type = reloc->howto->type; + + /* If this is a REFHI reloc, the next one must be a REFLO + reloc for the same symbol. */ + BFD_ASSERT (in.r_type != ECOFF_R_REFHI + || (reloc_ptr_ptr < reloc_end + && (reloc_ptr_ptr[1]->howto + != (reloc_howto_type *) NULL) + && (reloc_ptr_ptr[1]->howto->type + == ECOFF_R_REFLO) + && (sym == *reloc_ptr_ptr[1]->sym_ptr_ptr))); + if ((sym->flags & BSF_SECTION_SYM) == 0) { in.r_symndx = ecoff_get_sym_index (*reloc->sym_ptr_ptr); @@ -3992,6 +4047,8 @@ static CONST bfd_coff_backend_data bfd_ecoff_std_swap_table = { #define ecoff_bfd_get_relocated_section_contents \ bfd_generic_get_relocated_section_contents #define ecoff_bfd_relax_section bfd_generic_relax_section +#define ecoff_bfd_make_debug_symbol \ + ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr) bfd_target ecoff_little_vec = { @@ -4020,7 +4077,6 @@ bfd_target ecoff_little_vec = {bfd_false, ecoff_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, JUMP_TABLE (ecoff), - 0, 0, (PTR) &bfd_ecoff_std_swap_table }; @@ -4049,7 +4105,6 @@ bfd_target ecoff_big_vec = {bfd_false, ecoff_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, JUMP_TABLE(ecoff), - 0, 0, (PTR) &bfd_ecoff_std_swap_table /* Note that there is another bfd_target just above this one. If you are adding initializers here, you should be adding them there diff --git a/bfd/coff-msym.c b/bfd/coff-msym.c index 159b52a..e2f71a4 100644 --- a/bfd/coff-msym.c +++ b/bfd/coff-msym.c @@ -35,10 +35,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Swap in the symbolic header. */ void -DEFUN (ecoff_swap_hdr_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct hdr_ext *ext_copy AND - HDRR *intern) +ecoff_swap_hdr_in (abfd, ext_copy, intern) + bfd *abfd; + struct hdr_ext *ext_copy; + HDRR *intern; { struct hdr_ext ext[1]; @@ -79,10 +79,10 @@ DEFUN (ecoff_swap_hdr_in, (abfd, ext_copy, intern), /* Swap out the symbolic header. */ void -DEFUN (ecoff_swap_hdr_out, (abfd, intern_copy, ext), - bfd *abfd AND - HDRR *intern_copy AND - struct hdr_ext *ext) +ecoff_swap_hdr_out (abfd, intern_copy, ext) + bfd *abfd; + HDRR *intern_copy; + struct hdr_ext *ext; { HDRR intern[1]; @@ -123,10 +123,10 @@ DEFUN (ecoff_swap_hdr_out, (abfd, intern_copy, ext), /* Swap in the file descriptor record. */ void -DEFUN (ecoff_swap_fdr_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct fdr_ext *ext_copy AND - FDR *intern) +ecoff_swap_fdr_in (abfd, ext_copy, intern) + bfd *abfd; + struct fdr_ext *ext_copy; + FDR *intern; { struct fdr_ext ext[1]; @@ -181,10 +181,10 @@ DEFUN (ecoff_swap_fdr_in, (abfd, ext_copy, intern), /* Swap out the file descriptor record. */ void -DEFUN (ecoff_swap_fdr_out, (abfd, intern_copy, ext), - bfd *abfd AND - FDR *intern_copy AND - struct fdr_ext *ext) +ecoff_swap_fdr_out (abfd, intern_copy, ext) + bfd *abfd; + FDR *intern_copy; + struct fdr_ext *ext; { FDR intern[1]; @@ -242,10 +242,10 @@ DEFUN (ecoff_swap_fdr_out, (abfd, intern_copy, ext), /* Swap in the procedure descriptor record. */ void -DEFUN (ecoff_swap_pdr_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct pdr_ext *ext_copy AND - PDR *intern) +ecoff_swap_pdr_in (abfd, ext_copy, intern) + bfd *abfd; + struct pdr_ext *ext_copy; + PDR *intern; { struct pdr_ext ext[1]; @@ -275,10 +275,10 @@ DEFUN (ecoff_swap_pdr_in, (abfd, ext_copy, intern), /* Swap out the procedure descriptor record. */ void -DEFUN (ecoff_swap_pdr_out, (abfd, intern_copy, ext), - bfd *abfd AND - PDR *intern_copy AND - struct pdr_ext *ext) +ecoff_swap_pdr_out (abfd, intern_copy, ext) + bfd *abfd; + PDR *intern_copy; + struct pdr_ext *ext; { PDR intern[1]; @@ -308,10 +308,10 @@ DEFUN (ecoff_swap_pdr_out, (abfd, intern_copy, ext), /* Swap in a symbol record. */ void -DEFUN (ecoff_swap_sym_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct sym_ext *ext_copy AND - SYMR *intern) +ecoff_swap_sym_in (abfd, ext_copy, intern) + bfd *abfd; + struct sym_ext *ext_copy; + SYMR *intern; { struct sym_ext ext[1]; @@ -356,10 +356,10 @@ DEFUN (ecoff_swap_sym_in, (abfd, ext_copy, intern), /* Swap out a symbol record. */ void -DEFUN (ecoff_swap_sym_out, (abfd, intern_copy, ext), - bfd *abfd AND - SYMR *intern_copy AND - struct sym_ext *ext) +ecoff_swap_sym_out (abfd, intern_copy, ext) + bfd *abfd; + SYMR *intern_copy; + struct sym_ext *ext; { SYMR intern[1]; @@ -404,10 +404,10 @@ DEFUN (ecoff_swap_sym_out, (abfd, intern_copy, ext), /* Swap in an external symbol record. */ void -DEFUN (ecoff_swap_ext_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct ext_ext *ext_copy AND - EXTR *intern) +ecoff_swap_ext_in (abfd, ext_copy, intern) + bfd *abfd; + struct ext_ext *ext_copy; + EXTR *intern; { struct ext_ext ext[1]; @@ -437,10 +437,10 @@ DEFUN (ecoff_swap_ext_in, (abfd, ext_copy, intern), /* Swap out an external symbol record. */ void -DEFUN (ecoff_swap_ext_out, (abfd, intern_copy, ext), - bfd *abfd AND - EXTR *intern_copy AND - struct ext_ext *ext) +ecoff_swap_ext_out (abfd, intern_copy, ext) + bfd *abfd; + EXTR *intern_copy; + struct ext_ext *ext; { EXTR intern[1]; @@ -473,10 +473,10 @@ DEFUN (ecoff_swap_ext_out, (abfd, intern_copy, ext), info comes from the file header record (fh-fBigendian). */ void -DEFUN (ecoff_swap_tir_in, (bigend, ext_copy, intern), - int bigend AND - struct tir_ext *ext_copy AND - TIR *intern) +ecoff_swap_tir_in (bigend, ext_copy, intern) + int bigend; + struct tir_ext *ext_copy; + TIR *intern; { struct tir_ext ext[1]; @@ -525,14 +525,71 @@ DEFUN (ecoff_swap_tir_in, (bigend, ext_copy, intern), #endif } +/* Swap out a type information record. + BIGEND says whether AUX symbols are big-endian or little-endian; this + info comes from the file header record (fh-fBigendian). */ + +void +ecoff_swap_tir_out (bigend, intern_copy, ext) + int bigend; + TIR *intern_copy; + struct tir_ext *ext; +{ + TIR intern[1]; + + *intern = *intern_copy; /* Make it reasonable to do in-place. */ + + /* now the fun stuff... */ + if (bigend) { + ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0) + | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0) + | ((intern->bt << TIR_BITS1_BT_SH_BIG) + & TIR_BITS1_BT_BIG)); + ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG) + & TIR_BITS_TQ4_BIG) + | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG) + & TIR_BITS_TQ5_BIG)); + ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG) + & TIR_BITS_TQ0_BIG) + | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG) + & TIR_BITS_TQ1_BIG)); + ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG) + & TIR_BITS_TQ2_BIG) + | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG) + & TIR_BITS_TQ3_BIG)); + } else { + ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0) + | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0) + | ((intern->bt << TIR_BITS1_BT_SH_LITTLE) + & TIR_BITS1_BT_LITTLE)); + ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE) + & TIR_BITS_TQ4_LITTLE) + | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE) + & TIR_BITS_TQ5_LITTLE)); + ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE) + & TIR_BITS_TQ0_LITTLE) + | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE) + & TIR_BITS_TQ1_LITTLE)); + ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE) + & TIR_BITS_TQ2_LITTLE) + | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE) + & TIR_BITS_TQ3_LITTLE)); + } + +#ifdef TEST + if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0) + abort(); +#endif +} + /* Swap in a relative symbol record. BIGEND says whether it is in big-endian or little-endian format.*/ void -DEFUN (ecoff_swap_rndx_in, (bigend, ext_copy, intern), - int bigend AND - struct rndx_ext *ext_copy AND - RNDXR *intern) +ecoff_swap_rndx_in (bigend, ext_copy, intern) + int bigend; + struct rndx_ext *ext_copy; + RNDXR *intern; { struct rndx_ext ext[1]; @@ -567,10 +624,10 @@ DEFUN (ecoff_swap_rndx_in, (bigend, ext_copy, intern), big-endian or little-endian format.*/ void -DEFUN (ecoff_swap_rndx_out, (bigend, intern_copy, ext), - int bigend AND - RNDXR *intern_copy AND - struct rndx_ext *ext) +ecoff_swap_rndx_out (bigend, intern_copy, ext) + int bigend; + RNDXR *intern_copy; + struct rndx_ext *ext; { RNDXR intern[1]; @@ -604,10 +661,10 @@ DEFUN (ecoff_swap_rndx_out, (bigend, intern_copy, ext), /* Swap in a relative file descriptor. */ void -DEFUN (ecoff_swap_rfd_in, (abfd, ext, intern), - bfd *abfd AND - struct rfd_ext *ext AND - RFDT *intern) +ecoff_swap_rfd_in (abfd, ext, intern) + bfd *abfd; + struct rfd_ext *ext; + RFDT *intern; { *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd); @@ -621,10 +678,10 @@ DEFUN (ecoff_swap_rfd_in, (abfd, ext, intern), /* Swap out a relative file descriptor. */ void -DEFUN (ecoff_swap_rfd_out, (abfd, intern, ext), - bfd *abfd AND - RFDT *intern AND - struct rfd_ext *ext) +ecoff_swap_rfd_out (abfd, intern, ext) + bfd *abfd; + RFDT *intern; + struct rfd_ext *ext; { bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd); @@ -637,10 +694,10 @@ DEFUN (ecoff_swap_rfd_out, (abfd, intern, ext), /* Swap in an optimization symbol. */ void -DEFUN (ecoff_swap_opt_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct opt_ext *ext_copy AND - OPTR *intern) +ecoff_swap_opt_in (abfd, ext_copy, intern) + bfd *abfd; + struct opt_ext *ext_copy; + OPTR *intern; { struct opt_ext ext[1]; @@ -675,10 +732,10 @@ DEFUN (ecoff_swap_opt_in, (abfd, ext_copy, intern), /* Swap out an optimization symbol. */ void -DEFUN (ecoff_swap_opt_out, (abfd, intern_copy, ext), - bfd *abfd AND - OPTR *intern_copy AND - struct opt_ext *ext) +ecoff_swap_opt_out (abfd, intern_copy, ext) + bfd *abfd; + OPTR *intern_copy; + struct opt_ext *ext; { OPTR intern[1]; @@ -713,10 +770,10 @@ DEFUN (ecoff_swap_opt_out, (abfd, intern_copy, ext), /* Swap in a dense number. */ void -DEFUN (ecoff_swap_dnr_in, (abfd, ext_copy, intern), - bfd *abfd AND - struct dnr_ext *ext_copy AND - DNR *intern) +ecoff_swap_dnr_in (abfd, ext_copy, intern) + bfd *abfd; + struct dnr_ext *ext_copy; + DNR *intern; { struct dnr_ext ext[1]; @@ -734,10 +791,10 @@ DEFUN (ecoff_swap_dnr_in, (abfd, ext_copy, intern), /* Swap out a dense number. */ void -DEFUN (ecoff_swap_dnr_out, (abfd, intern_copy, ext), - bfd *abfd AND - DNR *intern_copy AND - struct dnr_ext *ext) +ecoff_swap_dnr_out (abfd, intern_copy, ext) + bfd *abfd; + DNR *intern_copy; + struct dnr_ext *ext; { DNR intern[1];