(struct elf_obj_tdata): Add field `thunk'.
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index 21f023ee23c49db2d75e5645138e5c9b61b4ae2c..f86029d4929d570addac89b592a39deec71b1e5f 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.
@@ -89,6 +89,11 @@ DEFUN(make_a_section_from_file,(abfd, hdr, target_index),
 
   return_section->target_index = target_index;
 
+  /* At least on i386-coff, the line number count for a shared library
+     section must be ignored.  */
+  if ((return_section->flags & SEC_SHARED_LIBRARY) != 0)
+    return_section->lineno_count = 0;
+
   if (hdr->s_nreloc != 0)
     return_section->flags |= SEC_RELOC;
   /* FIXME: should this check 'hdr->s_size > 0' */
@@ -827,13 +832,12 @@ DEFUN(coff_write_symbols,(abfd),
   else {
     /* We would normally not write anything here, but we'll write
        out 4 so that any stupid coff reader which tries to read
-       the string table even when there isn't one won't croak.
-       */
-
-    uint32e_type size = 4;
-    size =  size;
-    bfd_write((PTR)&size, 1, sizeof(size), abfd);
+       the string table even when there isn't one won't croak.  */
+    unsigned int size = 4;
+    bfd_byte buffer[4];
 
+    bfd_h_put_32 (abfd, size, buffer);
+    bfd_write((PTR) buffer, 1, sizeof (buffer), abfd);
   }
 }
 
@@ -1125,7 +1129,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 +1227,7 @@ bfd            *abfd)
   }
 
   obj_raw_syments(abfd) = internal;
+  obj_raw_syment_count(abfd) = internal_ptr - internal;
 
   return (internal);
 }                              /* coff_get_normalized_symtab() */
@@ -1256,11 +1261,13 @@ DEFUN (coff_make_empty_symbol, (abfd),
   return &new->symbol;
 }
 
+/* Make a debugging symbol.  */
+
 asymbol *
-DEFUN (coff_make_debug_symbol, (abfd, ptr, sz),
-       bfd *abfd AND
-       PTR ptr AND
-       unsigned long sz)
+coff_bfd_make_debug_symbol (abfd, ptr, sz)
+     bfd *abfd;
+     PTR ptr;
+     unsigned long sz;
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
   if (new == NULL) {
@@ -1276,6 +1283,15 @@ DEFUN (coff_make_debug_symbol, (abfd, ptr, sz),
   return &new->symbol;
 }
 
+void
+coff_get_symbol_info (abfd, symbol, ret)
+     bfd *abfd;
+     asymbol *symbol;
+     symbol_info *ret;
+{
+  bfd_symbol_info (symbol, ret);
+}
+
 /* Print out information about COFF symbol.  */
 
 void
@@ -1299,15 +1315,6 @@ coff_print_symbol (abfd, filep, symbol, how)
               coffsymbol(symbol)->lineno ? "l" : " ");
       break;
 
-    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:
       if (coffsymbol(symbol)->native) 
        {
@@ -1403,14 +1410,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;
@@ -1444,17 +1451,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;
@@ -1468,13 +1477,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++;
   }
@@ -1483,7 +1493,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.024961 seconds and 4 git commands to generate.