1999-09-11 Donn Terry <donn@interix.com>
[deliverable/binutils-gdb.git] / bfd / coffswap.h
index 28c441545dd9542dae44c8c9547a868f90c6ec0b..c9f25d62a54169798475787e01e3b759ae5639c0 100644 (file)
@@ -1,5 +1,6 @@
 /* Generic COFF swapping routines, for BFD.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -168,6 +169,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #ifndef PUT_SCNHDR_LNNOPTR
 #define PUT_SCNHDR_LNNOPTR bfd_h_put_32
 #endif
+#ifndef GET_SCNHDR_NRELOC
+#define GET_SCNHDR_NRELOC bfd_h_get_16
+#endif
+#ifndef PUT_SCNHDR_NRELOC
+#define PUT_SCNHDR_NRELOC bfd_h_put_16
+#endif
+#ifndef GET_SCNHDR_NLNNO
+#define GET_SCNHDR_NLNNO bfd_h_get_16
+#endif
+#ifndef PUT_SCNHDR_NLNNO
+#define PUT_SCNHDR_NLNNO bfd_h_put_16
+#endif
+#ifndef GET_SCNHDR_FLAGS
+#define GET_SCNHDR_FLAGS bfd_h_get_32
+#endif
+#ifndef PUT_SCNHDR_FLAGS
+#define PUT_SCNHDR_FLAGS bfd_h_put_32
+#endif
+
 
 static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
 static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
@@ -269,11 +289,9 @@ coff_swap_filehdr_in (abfd, src, dst)
   filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
   filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
   filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
-/* start-sanitize-tic80 */
 #ifdef TIC80_TARGET_ID
   filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id);
 #endif
-/* end-sanitize-tic80 */
 
 #ifdef COFF_ADJUST_FILEHDR_IN_POST
   COFF_ADJUST_FILEHDR_IN_POST (abfd, src, dst);
@@ -300,11 +318,9 @@ coff_swap_filehdr_out (abfd, in, out)
   bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
   bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
   bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
-/* start-sanitize-tic80 */
 #ifdef TIC80_TARGET_ID
   bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id);
 #endif
-/* end-sanitize-tic80 */
 
 #ifdef COFF_ADJUST_FILEHDR_OUT_POST
   COFF_ADJUST_FILEHDR_OUT_POST (abfd, in, out);
@@ -407,7 +423,16 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
 #if FILNMLEN != E_FILNMLEN
            -> Error, we need to cope with truncating or extending FILNMLEN!;
 #else
-           memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+           if (numaux > 1)
+             {
+               if (indx == 0)
+                 memcpy (in->x_file.x_fname, ext->x_file.x_fname,
+                         numaux * sizeof (AUXENT));
+             }
+           else
+             {
+               memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+             }
 #endif
          }
       goto end;
@@ -488,7 +513,10 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
     in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
   }
 
-end:
+end: ;
+  /* the semicolon is because MSVC doesn't like labels at
+     end of block. */
+
 #ifdef COFF_ADJUST_AUX_IN_POST
   COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
 #endif
@@ -500,8 +528,8 @@ coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
      PTR       inp;
      int   type;
      int   class;
-     int   indx;
-     int   numaux;
+     int   indx ATTRIBUTE_UNUSED;
+     int   numaux ATTRIBUTE_UNUSED;
      PTR       extp;
 {
   union internal_auxent *in = (union internal_auxent *)inp;
@@ -798,16 +826,15 @@ coff_swap_scnhdr_in (abfd, ext, in)
     GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
   scnhdr_int->s_lnnoptr =
     GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
-  scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
-#if defined(M88)
-  scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
-  scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#else
-  scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
-  scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
-#endif
+  scnhdr_int->s_flags =
+    GET_SCNHDR_FLAGS (abfd, (bfd_byte *) scnhdr_ext->s_flags);
+  scnhdr_int->s_nreloc =
+    GET_SCNHDR_NRELOC (abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
+  scnhdr_int->s_nlnno =
+    GET_SCNHDR_NLNNO (abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
 #ifdef I960
-  scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
+  scnhdr_int->s_align =
+    GET_SCNHDR_ALIGN (abfd, (bfd_byte *) scnhdr_ext->s_align);
 #endif
 #ifdef COFF_ADJUST_SCNHDR_IN_POST
   COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
@@ -844,7 +871,8 @@ coff_swap_scnhdr_out (abfd, in, out)
                     (bfd_byte *) scnhdr_ext->s_relptr);
   PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
                      (bfd_byte *) scnhdr_ext->s_lnnoptr);
-  PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
+  PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags,
+                   (bfd_byte *) scnhdr_ext->s_flags);
 #if defined(M88)
   PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
   PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
@@ -858,7 +886,7 @@ coff_swap_scnhdr_out (abfd, in, out)
       memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
       buf[sizeof (scnhdr_int->s_name)] = '\0';
       (*_bfd_error_handler)
-       ("%s: warning: %s: line number overflow: 0x%lx > 0xffff",
+       (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
         bfd_get_filename (abfd),
         buf, scnhdr_int->s_nlnno);
       PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
@@ -871,7 +899,7 @@ coff_swap_scnhdr_out (abfd, in, out)
 
       memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
       buf[sizeof (scnhdr_int->s_name)] = '\0';
-      (*_bfd_error_handler) ("%s: %s: reloc overflow: 0x%lx > 0xffff",
+      (*_bfd_error_handler) (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
                             bfd_get_filename (abfd),
                             buf, scnhdr_int->s_nreloc);
       bfd_set_error (bfd_error_file_truncated);
@@ -880,8 +908,8 @@ coff_swap_scnhdr_out (abfd, in, out)
     }
 #endif
 
-#if defined(I960)
-  PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
+#ifdef I960
+  PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
 #endif
 #ifdef COFF_ADJUST_SCNHDR_OUT_POST
   COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
This page took 0.024361 seconds and 4 git commands to generate.