* libhppa.h: #undef e_* symbols which come from <machine/som.h>
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index 4e410fdc86674eae9e3086fb664a81dedf88d4fc..5c4b9d493dcfc44c828a231b7c6dda82ef927f70 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for the generic parts of COFF, for BFD.
-   Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -369,7 +369,7 @@ struct internal_syment *syment)
 {
 
   /* Normalize the symbol flags */
-  if (coff_symbol_ptr->symbol.section == &bfd_com_section) {
+  if (bfd_is_com_section (coff_symbol_ptr->symbol.section)) {
     /* a common symbol is undefined with a value */
     syment->n_scnum = N_UNDEF;
     syment->n_value = coff_symbol_ptr->symbol.value;
@@ -664,7 +664,7 @@ DEFUN(coff_write_alien_symbol,(abfd, symbol, written),
       native->u.syment.n_scnum =  N_UNDEF;
       native->u.syment.n_value =  symbol->value;
     }
-  else if (symbol->section == &bfd_com_section) 
+  else if (bfd_is_com_section (symbol->section))
   {
       native->u.syment.n_scnum =  N_UNDEF;
       native->u.syment.n_value =  symbol->value;
@@ -1125,7 +1125,7 @@ bfd            *abfd)
       internal_ptr->fix_tag = 0;
       internal_ptr->fix_end = 0;
       symbol_ptr = internal_ptr;
-    
+
       for (i = 0;
           i < symbol_ptr->u.syment.n_numaux;
           i++) 
@@ -1223,6 +1223,7 @@ bfd            *abfd)
   }
 
   obj_raw_syments(abfd) = internal;
+  obj_raw_syment_count(abfd) = internal_ptr - internal;
 
   return (internal);
 }                              /* coff_get_normalized_symtab() */
@@ -1276,113 +1277,106 @@ DEFUN (coff_make_debug_symbol, (abfd, ptr, sz),
   return &new->symbol;
 }
 
+/* Print out information about COFF symbol.  */
+
 void
-DEFUN(coff_print_symbol,(abfd, filep, symbol, how),
-      bfd            *abfd AND
-      PTR           filep AND
-      asymbol        *symbol AND
-      bfd_print_symbol_type how)
+coff_print_symbol (abfd, filep, symbol, how)
+     bfd *abfd;
+     PTR filep;
+     asymbol *symbol;
+     bfd_print_symbol_type how;
 {
-  FILE *file = (FILE *)filep;
-  switch (how) {
+  FILE *file = (FILE *) filep;
+
+  switch (how)
+    {
     case bfd_print_symbol_name:
-      fprintf(file, "%s", symbol->name);
+      fprintf (file, "%s", symbol->name);
       break;
+
     case bfd_print_symbol_more:
-      fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native,
-             (unsigned long) coffsymbol(symbol)->lineno);
+      fprintf (file, "coff %s %s",
+              coffsymbol(symbol)->native ? "n" : "g",
+              coffsymbol(symbol)->lineno ? "l" : " ");
       break;
-    case bfd_print_symbol_nm:
-
-    {
-      CONST char *section_name = symbol->section->name;
-      bfd_print_symbol_vandf((PTR) file, symbol);
-
-       
-      fprintf(file, " %-5s %s %s %s",
-             section_name,
-             coffsymbol(symbol)->native ? "n" : "g",
-             coffsymbol(symbol)->lineno ? "l" : " ",
-             symbol->name);
-    }
-
 
+    case bfd_print_symbol_nm:
+      bfd_print_symbol_vandf ((PTR) file, symbol);
+      fprintf (file, " %-5s %s %s %s",
+              symbol->section->name,
+              coffsymbol(symbol)->native ? "n" : "g",
+              coffsymbol(symbol)->lineno ? "l" : " ",
+              symbol->name);
       break;
-    case bfd_print_symbol_all:
-      /* Print out the symbols in a reasonable way */
-    {
-      CONST char *section_name = symbol->section->name;
-
 
+    case bfd_print_symbol_all:
       if (coffsymbol(symbol)->native) 
-      {
-       unsigned int aux;
-       combined_entry_type *combined = coffsymbol(symbol)->native;
-       combined_entry_type *root = obj_raw_syments(abfd);
-       
-       fprintf(file,"[%3d]",
-               combined - root);
-       
-
-       fprintf(file, "(sc %2d)(fl%4x)(ty%3x)(sc%3d) nx(%d) %08x %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,
-               combined->u.syment.n_value,
-               symbol->name
-               );
-       for (aux = 0; aux < combined->u.syment.n_numaux; aux++) 
        {
-         fprintf(file,"\n");
-         switch (combined->u.syment.n_sclass) {
-           case C_FILE:
-             fprintf(file, "File ");
-             break;
-           default:
-             fprintf(file, "AUX lnno %x size %x tagndx %x",
-                     combined[aux+1].u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
-                     combined[aux+1].u.auxent.x_sym.x_misc.x_lnsz.x_size,
-                     combined[aux+1].u.auxent.x_sym.x_tagndx.l);
-             break;
-    
+         unsigned int aux;
+         combined_entry_type *combined = coffsymbol (symbol)->native;
+         combined_entry_type *root = obj_raw_syments (abfd);
+         struct lineno_cache_entry *l = coffsymbol(symbol)->lineno;
+       
+         fprintf (file,"[%3d]", combined - root);
+
+         fprintf (file,
+                  "(sc %2d)(fl 0x%02x)(ty %3x)(sc %3d) (nx %d) 0x%08x %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,
+                  combined->u.syment.n_value,
+                  symbol->name);
+
+         for (aux = 0; aux < combined->u.syment.n_numaux; aux++) 
+           {
+             combined_entry_type *auxp = combined + aux + 1;
+             long tagndx;
+
+             if (auxp->fix_tag)
+               tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root;
+             else
+               tagndx = auxp->u.auxent.x_sym.x_tagndx.l;
+
+             fprintf (file, "\n");
+             switch (combined->u.syment.n_sclass)
+               {
+               case C_FILE:
+                 fprintf (file, "File ");
+                 break;
+               default:
+
+                 fprintf (file, "AUX lnno %d size 0x%x tagndx %d",
+                          auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
+                          auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size,
+                          tagndx);
+                 break;
+               }
            }
-
-       }
        
-      {
-       struct lineno_cache_entry *l = coffsymbol(symbol)->lineno;
-       if (l) 
+         if (l)
+           {
+             printf ("\n%s :", l->u.sym->name);
+             l++;
+             while (l->line_number) 
+               {
+                 printf ("\n%4d : 0x%x",
+                         l->line_number,
+                         l->u.offset);
+                 l++;
+               }
+           }
+       } 
+      else
        {
-         printf("\n%s :", l->u.sym->name);
-         l++;
-         while (l->line_number) 
-         {
-           printf("\n%4d : %x", 
-                  l->line_number,
-                  l->u.offset);
-           l++;
-           
-         }
-       }
-      }
-
-    
-
-      } 
-
-      else {
-         bfd_print_symbol_vandf((PTR) file, symbol);
-         fprintf(file, " %-5s %s %s %s",
-                 section_name,
-                 coffsymbol(symbol)->native ? "n" : "g",
-                 coffsymbol(symbol)->lineno ? "l" : " ",
-                 symbol->name);
+         bfd_print_symbol_vandf ((PTR) file, symbol);
+         fprintf (file, " %-5s %s %s %s",
+                  symbol->section->name,
+                  coffsymbol(symbol)->native ? "n" : "g",
+                  coffsymbol(symbol)->lineno ? "l" : " ",
+                  symbol->name);
        }
-
-    }
-       
     }
 }
 
@@ -1410,14 +1404,14 @@ DEFUN(coff_find_nearest_line,(abfd,
   static asection *cache_section;
   static bfd_vma  cache_offset;
   static unsigned int cache_i;
-  static alent   *cache_l;
+  static CONST char *cache_function;
+  static unsigned int    line_base = 0;
 
   unsigned int    i = 0;
   coff_data_type *cof = coff_data(abfd);
   /* Run through the raw syments if available */
   combined_entry_type *p;
   alent          *l;
-  unsigned int    line_base = 0;
 
 
   *filename_ptr = 0;
@@ -1451,17 +1445,19 @@ DEFUN(coff_find_nearest_line,(abfd,
       section == cache_section &&
       offset >= cache_offset) {
     i = cache_i;
-    l = cache_l;
+    *functionname_ptr = cache_function;
   }
   else {
     i = 0;
-    l = section->lineno;
   }
+  l = &section->lineno[i];
 
   for (; i < section->lineno_count; i++) {
     if (l->line_number == 0) {
       /* Get the symbol this line number points at */
       coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
+      if (coff->symbol.value > offset)
+       break;
       *functionname_ptr = coff->symbol.name;
       if (coff->native) {
        combined_entry_type  *s = coff->native;
@@ -1475,13 +1471,14 @@ DEFUN(coff_find_nearest_line,(abfd,
            */
          union internal_auxent   *a = &((s + 1)->u.auxent);
          line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
+         *line_ptr = line_base;
        }
       }
     }
     else {
       if (l->u.offset > offset)
        break;
-      *line_ptr = l->line_number + line_base + 1;
+      *line_ptr = l->line_number + line_base - 1;
     }
     l++;
   }
@@ -1490,7 +1487,7 @@ DEFUN(coff_find_nearest_line,(abfd,
   cache_section = section;
   cache_offset = offset;
   cache_i = i;
-  cache_l = l;
+  cache_function = *functionname_ptr;
 
   return true;
 }
This page took 0.026831 seconds and 4 git commands to generate.