]> Git Repo - binutils.git/blobdiff - bfd/coffcode.h
Remove i960 b.out bitrot.
[binutils.git] / bfd / coffcode.h
index 7862f844cfbf799f2680ea7d9804460c4a8389b6..150e511469cfdfd97740a0e2adee6aec2d5771f1 100644 (file)
@@ -255,6 +255,8 @@ CODE_FRAGMENT
 .   {* A pointer to the linenumber information for this symbol *}
 .struct lineno_cache_entry *lineno;
 .
+.   {* Have the line numbers been relocated yet ? *}
+.boolean done_lineno;
 .} coff_symbol_type;
 
 
@@ -554,84 +556,84 @@ DEFUN(coff_swap_sym_out,(abfd, inp, extp),
 }
 
 static void
-DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
+DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in),
       bfd            *abfd AND
       PTR            ext1 AND
       int             type AND
       int             class AND
-      PTR            in1)
+      union internal_auxent *in)
 {
   AUXENT    *ext = (AUXENT *)ext1;
-  union internal_auxent  *in = (union internal_auxent *)in1;
+
   switch (class) {
-  case C_FILE:
-    if (ext->x_file.x_fname[0] == 0) {
-      in->x_file.x_n.x_zeroes = 0;
-      in->x_file.x_n.x_offset = 
-       bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
-    } else {
+    case C_FILE:
+      if (ext->x_file.x_fname[0] == 0) {
+         in->x_file.x_n.x_zeroes = 0;
+         in->x_file.x_n.x_offset = 
+          bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
+       } else {
 #if FILNMLEN != E_FILNMLEN
-   -> Error, we need to cope with truncating or extending FILNMLEN!;
+           -> Error, we need to cope with truncating or extending FILNMLEN!;
 #else
-      memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+           memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
 #endif
-    }
-    break;
+         }
+      break;
 
-  /* RS/6000 "csect" auxents */
+      /* RS/6000 "csect" auxents */
 #ifdef RS6000COFF_C
-  case C_EXT:
-  case C_HIDEXT:
-    in->x_csect.x_scnlen   = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen);
-    in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash);
-    in->x_csect.x_snhash   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash);
-    /* We don't have to hack bitfields in x_smtyp because it's defined by
-       shifts-and-ands, which are equivalent on all byte orders.  */
-    in->x_csect.x_smtyp    = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smtyp);
-    in->x_csect.x_smclas   = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smclas);
-    in->x_csect.x_stab     = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab);
-    in->x_csect.x_snstab   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab);
-    break;
+    case C_EXT:
+    case C_HIDEXT:
+      in->x_csect.x_scnlen   = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen);
+      in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash);
+      in->x_csect.x_snhash   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash);
+      /* We don't have to hack bitfields in x_smtyp because it's defined by
+        shifts-and-ands, which are equivalent on all byte orders.  */
+      in->x_csect.x_smtyp    = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smtyp);
+      in->x_csect.x_smclas   = bfd_h_get_8  (abfd, (bfd_byte *) ext->x_csect.x_smclas);
+      in->x_csect.x_stab     = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab);
+      in->x_csect.x_snstab   = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab);
+      break;
 #endif
 
-  case C_STAT:
+    case C_STAT:
 #ifdef C_LEAFSTAT
-  case C_LEAFSTAT:
+    case C_LEAFSTAT:
 #endif
-  case C_HIDDEN:
-    if (type == T_NULL) {
-      in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
-      in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
-      in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
-      break;
-    }
-  default:
-    in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
+    case C_HIDDEN:
+      if (type == T_NULL) {
+         in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
+         in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
+         in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
+         break;
+       }
+    default:
+      in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
 #ifndef NO_TVNDX
-    in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+      in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
 #endif
 
-    if (ISARY(type) || class == C_BLOCK) {
+      if (ISARY(type) || class == C_BLOCK) {
 #if DIMNUM != E_DIMNUM
-   -> Error, we need to cope with truncating or extending DIMNUM!;
+         -> Error, we need to cope with truncating or extending DIMNUM!;
 #else
-      in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
-      in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
-      in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
-      in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+         in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+         in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+         in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+         in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
 #endif
-    }
+       }
       in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
       in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
 
-    if (ISFCN(type)) {
-      in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
-    }
-    else {
-      in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
-      in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
+      if (ISFCN(type)) {
+         in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+       }
+      else {
+         in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
+         in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
+       }
     }
-  }
 }
 
 static unsigned int
@@ -1495,7 +1497,7 @@ unsigned int written)
 
   coff_swap_sym_out(abfd, &native->u.syment, &buf);
   bfd_write((PTR)& buf, 1, SYMESZ, abfd);
-  for (j = 0; j != native->u.syment.n_numaux;  j++)
+  for (j = 0; j <= native->u.syment.n_numaux;  j++)
   {
     AUXENT buf1;
     bzero((PTR)&buf, AUXESZ);
@@ -1593,7 +1595,7 @@ unsigned int written)
 
   alent          *lineno = symbol->lineno;
 
-  if (lineno) {
+  if (lineno && !symbol->done_lineno) {
     unsigned int    count = 0;
     lineno[count].u.offset = written;
     if (native->u.syment.n_numaux) {
@@ -1613,6 +1615,8 @@ unsigned int written)
          symbol->symbol.section->output_offset;
       count++;
     }
+    symbol->done_lineno = true;
+    
     symbol->symbol.section->output_section->moving_line_filepos +=
       count * LINESZ;
   }
@@ -1804,6 +1808,7 @@ bfd            *abfd;
   }                            /* on error */
   new->native = 0;
   new->lineno = (alent *) NULL;
+  new->done_lineno = false;
   new->symbol.the_bfd = abfd;
   return &new->symbol;
 }
@@ -1875,15 +1880,32 @@ DEFUN(coff_print_symbol,(ignore_abfd, filep, symbol, how),
              fprintf(file, "File ");
              break;
            default:
-             fprintf(file, "AUX lnno %x size %x",
+             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_misc.x_lnsz.x_size,
+                     combined[aux+1].u.auxent.x_sym.x_tagndx.l);
              break;
     
            }
 
        }
        
+      {
+       struct lineno_cache_entry *l = coffsymbol(symbol)->lineno;
+       if (l) 
+       {
+         printf("\n%s :", l->u.sym->name);
+         l++;
+         while (l->line_number) 
+         {
+           printf("\n%4d : %x", 
+                  l->line_number,
+                  l->u.offset);
+           l++;
+           
+         }
+       }
+      }
 
     
 
@@ -2289,10 +2311,12 @@ DEFUN(coff_write_object_contents,(abfd),
     same but is not a reasonable time. -- [email protected]
     */
   /*
-    Well, I like it, so I'm conditionally compiling it in.
+    Well, I like it, and now we have *customers* who have requested it,
+    so I'm conditionally compiling it in.
+
     */
-#ifdef COFF_TIMESTAMP
+#ifndef NOCOFF_TIMESTAMP
   internal_f.f_timdat = time(0);
 #else
   internal_f.f_timdat = 0;
@@ -2318,12 +2342,12 @@ DEFUN(coff_write_object_contents,(abfd),
    internal_f.f_flags |= F_LSYMS;
   if (abfd->flags & EXEC_P)
    internal_f.f_flags |= F_EXEC;
-#if M88
-  internal_f.f_flags |= F_AR32W;
-#else
+
   if (!abfd->xvec->byteorder_big_p)
    internal_f.f_flags |= F_AR32WR;
-#endif
+  else 
+  internal_f.f_flags |= F_AR32W;
+
   /*
     FIXME, should do something about the other byte orders and
     architectures.
@@ -2638,6 +2662,7 @@ bfd            *abfd)
 {
   combined_entry_type          *internal;
   combined_entry_type          *internal_ptr;
+  combined_entry_type          *symbol_ptr;
   combined_entry_type         *internal_end;
   SYMENT *raw;
   SYMENT *raw_src;
@@ -2648,12 +2673,12 @@ bfd            *abfd)
 
   unsigned int raw_size;
   if (obj_raw_syments(abfd) != (combined_entry_type *)NULL) {
-    return obj_raw_syments(abfd);
-  }
+      return obj_raw_syments(abfd);
+    }
   if ((size = bfd_get_symcount(abfd) * sizeof(combined_entry_type)) == 0) {
-    bfd_error = no_symbols;
-    return (NULL);
-  }
+      bfd_error = no_symbols;
+      return (NULL);
+    }
 
   internal = (combined_entry_type *)bfd_alloc(abfd, size);
   internal_end = internal + bfd_get_symcount(abfd);
@@ -2663,9 +2688,9 @@ bfd            *abfd)
 
   if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
       || bfd_read((PTR)raw, raw_size, 1, abfd) != raw_size) {
-    bfd_error = system_call_error;
-    return (NULL);
-  }
+      bfd_error = system_call_error;
+      return (NULL);
+    }
   /* mark the end of the symbols */
   raw_end = raw + bfd_get_symcount(abfd);
   /*
@@ -2678,59 +2703,62 @@ bfd            *abfd)
        raw_src < raw_end;
        raw_src++, internal_ptr++) {
 
-    unsigned int i;
-    coff_swap_sym_in(abfd, (char *)raw_src, (char *)&internal_ptr->u.syment);
-    internal_ptr->fix_tag = 0;
-    internal_ptr->fix_end = 0;
-
-    for (i = internal_ptr->u.syment.n_numaux;
-        i;
-        --i, raw_src++, internal_ptr++) {
-
-      (internal_ptr+1)->fix_tag = 0;
-      (internal_ptr+1)->fix_end = 0;
-
-      coff_swap_aux_in(abfd, (char *)(raw_src +1),
-                      internal_ptr->u.syment.n_type,
-                      internal_ptr->u.syment.n_sclass,
-                      &(internal_ptr+1)->u.auxent);
-
-      coff_pointerize_aux(abfd,
-                         internal,
-                         internal_ptr->u.syment.n_type,
-                         internal_ptr->u.syment.n_sclass,
-                         internal_ptr +1);
+      unsigned int i;
+      coff_swap_sym_in(abfd, (char *)raw_src, (char *)&internal_ptr->u.syment);
+      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++) 
+      {
+       internal_ptr++;
+       raw_src++;
+      
+       internal_ptr->fix_tag = 0;
+       internal_ptr->fix_end = 0;
+       coff_swap_aux_in(abfd, (char *)(raw_src),
+                        symbol_ptr->u.syment.n_type,
+                        symbol_ptr->u.syment.n_sclass,
+                        &(internal_ptr->u.auxent));
+
+       coff_pointerize_aux(abfd,
+                           internal,
+                           symbol_ptr->u.syment.n_type,
+                           symbol_ptr->u.syment.n_sclass,
+                           internal_ptr);
+      }
     }
-  }
 
   /* Free all the raw stuff */
   bfd_release(abfd, raw);
 
   for (internal_ptr = internal; internal_ptr < internal_end;
        internal_ptr ++)
-      {
-       if (internal_ptr->u.syment.n_sclass == C_FILE) {
-         /* make a file symbol point to the name in the auxent, since
-            the text ".file" is redundant */
-         if ((internal_ptr+1)->u.auxent.x_file.x_n.x_zeroes == 0) {
+  {
+    if (internal_ptr->u.syment.n_sclass == C_FILE) {
+       /* make a file symbol point to the name in the auxent, since
+          the text ".file" is redundant */
+       if ((internal_ptr+1)->u.auxent.x_file.x_n.x_zeroes == 0) {
            /* the filename is a long one, point into the string table */
            if (string_table == NULL) {
-             string_table = build_string_table(abfd);
-           }
+               string_table = build_string_table(abfd);
+             }
 
            internal_ptr->u.syment._n._n_n._n_offset =
-             (int) (string_table - 4 +
-                    (internal_ptr+1)->u.auxent.x_file.x_n.x_offset);
+            (int) (string_table - 4 +
+                   (internal_ptr+1)->u.auxent.x_file.x_n.x_offset);
          }
-         else {
+       else {
            /* ordinary short filename, put into memory anyway */
            internal_ptr->u.syment._n._n_n._n_offset = (int)
-             copy_name(abfd, (internal_ptr+1)->u.auxent.x_file.x_fname,
-                       FILNMLEN);
+            copy_name(abfd, (internal_ptr+1)->u.auxent.x_file.x_fname,
+                      FILNMLEN);
          }
-       }
-       else {
-         if (internal_ptr->u.syment._n._n_n._n_zeroes != 0) {
+      }
+    else {
+       if (internal_ptr->u.syment._n._n_n._n_zeroes != 0) {
            /* This is a "short" name.  Make it long.  */
            unsigned long   i = 0;
            char           *newstring = NULL;
@@ -2738,39 +2766,39 @@ bfd            *abfd)
            /* find the length of this string without walking into memory
               that isn't ours.  */
            for (i = 0; i < 8; ++i) {
-             if (internal_ptr->u.syment._n._n_name[i] == '\0') {
-               break;
-             }                 /* if end of string */
-           }                   /* possible lengths of this string. */
+               if (internal_ptr->u.syment._n._n_name[i] == '\0') {
+                   break;
+                 }             /* if end of string */
+             }                 /* possible lengths of this string. */
 
            if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) {
-             bfd_error = no_memory;
-             return (NULL);
-           }                   /* on error */
+               bfd_error = no_memory;
+               return (NULL);
+             }                 /* on error */
            bzero(newstring, i);
            strncpy(newstring, internal_ptr->u.syment._n._n_name, i-1);
            internal_ptr->u.syment._n._n_n._n_offset =  (int) newstring;
            internal_ptr->u.syment._n._n_n._n_zeroes = 0;
          }
-         else if (!SYMNAME_IN_DEBUG(&internal_ptr->u.syment)) {
+       else if (!SYMNAME_IN_DEBUG(&internal_ptr->u.syment)) {
            /* Long name already.  Point symbol at the string in the table.  */
            if (string_table == NULL) {
-             string_table = build_string_table(abfd);
-           }
+               string_table = build_string_table(abfd);
+             }
            internal_ptr->u.syment._n._n_n._n_offset = (int)
-             (string_table - 4 + internal_ptr->u.syment._n._n_n._n_offset);
+            (string_table - 4 + internal_ptr->u.syment._n._n_n._n_offset);
          }
-         else {
+       else {
            /* Long name in debug section.  Very similar.  */
            if (debug_section == NULL) {
-             debug_section = build_debug_section(abfd);
-           }
+               debug_section = build_debug_section(abfd);
+             }
            internal_ptr->u.syment._n._n_n._n_offset = (int)
-             (debug_section + internal_ptr->u.syment._n._n_n._n_offset);
+            (debug_section + internal_ptr->u.syment._n._n_n._n_offset);
          }
-       }
-       internal_ptr += internal_ptr->u.syment.n_numaux;
       }
+    internal_ptr += internal_ptr->u.syment.n_numaux;
+  }
 
   obj_raw_syments(abfd) = internal;
 
@@ -3616,19 +3644,18 @@ DEFUN(jmp1,(input_section, symbols, r, shrink),
   return shrink;      
 }
 
-extern boolean 
-DEFUN(bfd_coff_relax_section,(abfd, i, symbols, seclet),
+static boolean 
+DEFUN(bfd_coff_relax_section,(abfd, i, symbols),
       bfd *abfd AND
       asection *i AND
-      asymbol **symbols AND
-      bfd_seclet_type *seclet)
+      asymbol **symbols)
 {
   
   /* Get enough memory to hold the stuff */
   bfd *input_bfd = i->owner;
   asection *input_section = i;
   int shrink = 0 ;
-  int new = 0;
+  boolean new = false;
   
   bfd_size_type reloc_size = bfd_get_reloc_upper_bound(input_bfd,
                                                       input_section);
@@ -3653,12 +3680,12 @@ DEFUN(bfd_coff_relax_section,(abfd, i, symbols, seclet),
          
        case R_MOVB1:
          shrink = movb1(input_section, symbols, r, shrink);
-         new = 1;
+         new = true;
          
          break;
        case R_JMP1:
          shrink = jmp1(input_section, symbols, r, shrink);
-         new = 1;
+         new = true;
          
          break;
        }
@@ -3683,9 +3710,9 @@ DEFUN(bfd_coff_get_relocated_section_contents,(in_abfd, seclet),
   bfd *input_bfd = seclet->u.indirect.section->owner;
   asection *input_section = seclet->u.indirect.section;
 
-  char *data = malloc(input_section->_raw_size);
-  char *dst = data;
-  char *prev_dst = data;
+  bfd_byte  *data = (bfd_byte *)malloc(input_section->_raw_size);
+  bfd_byte *dst = data;
+  bfd_byte *prev_dst = data;
 
   unsigned int gap = 0;
 
This page took 0.041764 seconds and 4 git commands to generate.