2001-08-23 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index 35e8f718e6a36396d2ff81ba173f0696fdf4c6ba..45eda875d5c56f2624764282a52e590ccaa9067c 100644 (file)
@@ -1,5 +1,6 @@
 /* Support for the generic parts of COFF, for BFD.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -46,13 +47,13 @@ static void coff_fix_symbol_name
   PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *,
           asection **, bfd_size_type *));
 static boolean coff_write_symbol
-  PARAMS ((bfd *, asymbol *, combined_entry_type *, unsigned int *,
+  PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_vma *,
           bfd_size_type *, asection **, bfd_size_type *));
 static boolean coff_write_alien_symbol
-  PARAMS ((bfd *, asymbol *, unsigned int *, bfd_size_type *,
+  PARAMS ((bfd *, asymbol *, bfd_vma *, bfd_size_type *,
           asection **, bfd_size_type *));
 static boolean coff_write_native_symbol
-  PARAMS ((bfd *, coff_symbol_type *, unsigned int *, bfd_size_type *,
+  PARAMS ((bfd *, coff_symbol_type *, bfd_vma *, bfd_size_type *,
           asection **, bfd_size_type *));
 static void coff_pointerize_aux
   PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
@@ -81,6 +82,8 @@ make_a_section_from_file (abfd, hdr, target_index)
 {
   asection *return_section;
   char *name;
+  boolean result = true;
+  flagword flags;
 
   name = NULL;
 
@@ -141,8 +144,12 @@ make_a_section_from_file (abfd, hdr, target_index)
   return_section->userdata = NULL;
   return_section->next = (asection *) NULL;
   return_section->target_index = target_index;
-  return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name,
-                                                          return_section);
+
+  if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section,
+                                        & flags))
+    result = false;
+  
+  return_section->flags = flags;
 
   /* At least on i386-coff, the line number count for a shared library
      section must be ignored.  */
@@ -154,7 +161,8 @@ make_a_section_from_file (abfd, hdr, target_index)
   /* FIXME: should this check 'hdr->s_size > 0' */
   if (hdr->s_scnptr != 0)
     return_section->flags |= SEC_HAS_CONTENTS;
-  return true;
+
+  return result;
 }
 
 /* Read in a COFF object and make it into a BFD.  This is used by
@@ -748,8 +756,9 @@ coff_mangle_symbols (bfd_ptr)
          if (s->fix_value)
            {
              /* FIXME: We should use a union here.  */
-             s->u.syment.n_value =
-               ((combined_entry_type *) s->u.syment.n_value)->offset;
+             s->u.syment.n_value = 
+               (bfd_vma)((combined_entry_type *) 
+                         ((unsigned long) s->u.syment.n_value))->offset;
              s->fix_value = 0;
            }
          if (s->fix_line)
@@ -920,7 +929,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p,
      bfd *abfd;
      asymbol *symbol;
      combined_entry_type *native;
-     unsigned int *written;
+     bfd_vma *written;
      bfd_size_type *string_size_p;
      asection **debug_string_section_p;
      bfd_size_type *debug_string_size_p;
@@ -1005,7 +1014,7 @@ coff_write_alien_symbol (abfd, symbol, written, string_size_p,
                         debug_string_section_p, debug_string_size_p)
      bfd *abfd;
      asymbol *symbol;
-     unsigned int *written;
+     bfd_vma *written;
      bfd_size_type *string_size_p;
      asection **debug_string_section_p;
      bfd_size_type *debug_string_size_p;
@@ -1073,7 +1082,7 @@ coff_write_native_symbol (abfd, symbol, written, string_size_p,
                          debug_string_section_p, debug_string_size_p)
      bfd *abfd;
      coff_symbol_type *symbol;
-     unsigned int *written;
+     bfd_vma *written;
      bfd_size_type *string_size_p;
      asection **debug_string_section_p;
      bfd_size_type *debug_string_size_p;
@@ -1146,7 +1155,7 @@ coff_write_symbols (abfd)
   bfd_size_type debug_string_size;
   unsigned int i;
   unsigned int limit = bfd_get_symcount (abfd);
-  unsigned int written = 0;
+  bfd_signed_vma written = 0;
   asymbol **p;
 
   string_size = 0;
@@ -1916,11 +1925,8 @@ coff_get_symbol_info (abfd, symbol, ret)
   if (coffsymbol (symbol)->native != NULL
       && coffsymbol (symbol)->native->fix_value)
     {
-      combined_entry_type *psym;
-
-      psym = ((combined_entry_type *)
-             coffsymbol (symbol)->native->u.syment.n_value);
-      ret->value = (bfd_vma) (psym - obj_raw_syments (abfd));
+      ret->value = coffsymbol (symbol)->native->u.syment.n_value -
+       (unsigned long) obj_raw_syments (abfd);
     }
 }
 
@@ -1944,8 +1950,8 @@ bfd_coff_get_syment (abfd, symbol, psyment)
   *psyment = csym->native->u.syment;
 
   if (csym->native->fix_value)
-    psyment->n_value = ((combined_entry_type *) psyment->n_value
-                       - obj_raw_syments (abfd));
+    psyment->n_value = psyment->n_value - 
+      (unsigned long) obj_raw_syments (abfd);
 
   /* FIXME: We should handle fix_line here.  */
 
@@ -2022,7 +2028,7 @@ coff_print_symbol (abfd, filep, symbol, how)
     case bfd_print_symbol_all:
       if (coffsymbol (symbol)->native)
        {
-         unsigned long val;
+         bfd_vma val;
          unsigned int aux;
          combined_entry_type *combined = coffsymbol (symbol)->native;
          combined_entry_type *root = obj_raw_syments (abfd);
@@ -2031,12 +2037,11 @@ coff_print_symbol (abfd, filep, symbol, how)
          fprintf (file, "[%3ld]", (long) (combined - root));
 
          if (! combined->fix_value)
-           val = (unsigned long) combined->u.syment.n_value;
+           val = (bfd_vma) combined->u.syment.n_value;
          else
-           val = ((unsigned long)
-                  ((combined_entry_type *) combined->u.syment.n_value
-                   - root));
+           val = combined->u.syment.n_value - (unsigned long) root;
 
+#ifndef XCOFF64
          fprintf (file,
                   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
                   combined->u.syment.n_scnum,
@@ -2044,8 +2049,20 @@ coff_print_symbol (abfd, filep, symbol, how)
                   combined->u.syment.n_type,
                   combined->u.syment.n_sclass,
                   combined->u.syment.n_numaux,
+                  (unsigned long) val,
+                  symbol->name);
+#else
+         /* Print out the wide, 64 bit, symbol value */
+         fprintf (file,
+                  "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%016llx %s",
+                  combined->u.syment.n_scnum,
+                  combined->u.syment.n_flags,
+                  combined->u.syment.n_type,
+                  combined->u.syment.n_sclass,
+                  combined->u.syment.n_numaux,
                   val,
                   symbol->name);
+#endif
 
          for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
            {
@@ -2089,16 +2106,18 @@ coff_print_symbol (abfd, filep, symbol, how)
                case C_EXT:
                  if (ISFCN (combined->u.syment.n_type))
                    {
+                     long next, llnos;
+
+                     if (auxp->fix_end)
+                       next = (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
+                              - root);
+                     else
+                       next = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
+                     llnos = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr;
                      fprintf (file,
                               _("AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"),
-                              tagndx,
-                              auxp->u.auxent.x_sym.x_misc.x_fsize,
-                              auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr,
-                              (auxp->fix_end
-                               ? ((long)
-                                  (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
-                                   - root))
-                               : auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l));
+                              tagndx, auxp->u.auxent.x_sym.x_misc.x_fsize,
+                              llnos, next);
                      break;
                    }
                  /* else fall through */
@@ -2132,7 +2151,7 @@ coff_print_symbol (abfd, filep, symbol, how)
        }
       else
        {
-         bfd_print_symbol_vandf ((PTR) file, symbol);
+         bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
          fprintf (file, " %-5s %s %s %s",
                   symbol->section->name,
                   coffsymbol (symbol)->native ? "n" : "g",
@@ -2263,7 +2282,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
 
          /* Avoid endless loops on erroneous files by ensuring that
             we always move forward in the file.  */
-         if (p - cof->raw_syments >= p->u.syment.n_value)
+         if (p >= cof->raw_syments + p->u.syment.n_value)
            break;
 
          p = cof->raw_syments + p->u.syment.n_value;
This page took 0.026676 seconds and 4 git commands to generate.