2006-09-05 Bibo Mao <bibo.mao@intel.com>
[deliverable/binutils-gdb.git] / bfd / coffcode.h
index 917c0e4522bb91e5c26e1ae76b29e8d59c6bd02d..fa0a206a5ef7d71f779ac2ad991c03e95cc56641 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for the generic parts of most COFF variants, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -1560,6 +1560,10 @@ coff_new_section_hook (bfd * abfd, asection * section)
     section->alignment_power = bfd_xcoff_data_align_power (abfd);
 #endif
 
+  /* Set up the section symbol.  */
+  if (!_bfd_generic_new_section_hook (abfd, section))
+    return FALSE;
+
   /* Allocate aux records for section symbols, to store size and
      related info.
 
@@ -1888,12 +1892,6 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
       arch = bfd_arch_ia64;
       break;
 #endif
-#ifdef A29K_MAGIC_BIG
-    case A29K_MAGIC_BIG:
-    case A29K_MAGIC_LITTLE:
-      arch = bfd_arch_a29k;
-      break;
-#endif
 #ifdef ARMMAGIC
     case ARMMAGIC:
     case ARMPEMAGIC:
@@ -1961,6 +1959,23 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
       machine = 88100;
       break;
 #endif
+#ifdef Z80MAGIC
+    case Z80MAGIC:
+      arch = bfd_arch_z80;
+      switch (internal_f->f_flags & F_MACHMASK)
+       {
+       case 0:
+       case bfd_mach_z80strict << 12:
+       case bfd_mach_z80 << 12:
+       case bfd_mach_z80full << 12:
+       case bfd_mach_r800 << 12:
+         machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
+         break;
+       default:
+         return FALSE;
+       }
+      break;
+#endif
 #ifdef Z8KMAGIC
     case Z8KMAGIC:
       arch = bfd_arch_z8k;
@@ -2517,11 +2532,15 @@ coff_write_relocs (bfd * abfd, int first_undef)
                else
                  {
                    n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
-                   /* Take notice if the symbol reloc points to a symbol
-                      we don't have in our symbol table.  What should we
-                      do for this??  */
+                   /* Check to see if the symbol reloc points to a symbol
+                      we don't have in our symbol table.  */
                    if (n.r_symndx > obj_conv_table_size (abfd))
-                     abort ();
+                     {
+                       bfd_set_error (bfd_error_bad_value);
+                       _bfd_error_handler (_("%B: reloc against a non-existant symbol index: %ld"),
+                                           abfd, n.r_symndx);
+                       return FALSE;
+                     }
                  }
              }
 
@@ -2561,6 +2580,24 @@ coff_set_flags (bfd * abfd,
 {
   switch (bfd_get_arch (abfd))
     {
+#ifdef Z80MAGIC
+    case bfd_arch_z80:
+      *magicp = Z80MAGIC;
+      switch (bfd_get_mach (abfd))
+       {
+       case 0:
+       case bfd_mach_z80strict:
+       case bfd_mach_z80:
+       case bfd_mach_z80full:
+       case bfd_mach_r800:
+         *flagsp = bfd_get_mach (abfd) << 12;
+         break;
+       default:
+         return FALSE;
+       }
+      return TRUE;
+#endif
+
 #ifdef Z8KMAGIC
     case bfd_arch_z8k:
       *magicp = Z8KMAGIC;
@@ -2781,15 +2818,6 @@ coff_set_flags (bfd * abfd,
       break;
 #endif
 
-#ifdef A29K_MAGIC_BIG
-    case bfd_arch_a29k:
-      if (bfd_big_endian (abfd))
-       *magicp = A29K_MAGIC_BIG;
-      else
-       *magicp = A29K_MAGIC_LITTLE;
-      return TRUE;
-#endif
-
 #ifdef WE32KMAGIC
     case bfd_arch_we32k:
       *magicp = WE32KMAGIC;
@@ -3771,18 +3799,6 @@ coff_write_object_contents (bfd * abfd)
     internal_f.f_flags |= flags;
     /* ...and the "opt"hdr...  */
 
-#ifdef A29K
-#ifdef ULTRA3                  /* NYU's machine */
-    /* FIXME: This is a bogus check.  I really want to see if there
-       is a .shbss or a .shdata section, if so then set the magic
-       number to indicate a shared data executable.  */
-    if (internal_f.f_nscns >= 7)
-      internal_a.magic = SHMAGIC; /* Shared magic.  */
-    else
-#endif /* ULTRA3 */
-      internal_a.magic = NMAGIC; /* Assume separate i/d.  */
-#define __A_MAGIC_SET__
-#endif /* A29K */
 #ifdef TICOFF_AOUT_MAGIC
     internal_a.magic = TICOFF_AOUT_MAGIC;
 #define __A_MAGIC_SET__
@@ -3853,7 +3869,7 @@ coff_write_object_contents (bfd * abfd)
 
 #if defined(IA64)
 #define __A_MAGIC_SET__
-    internal_a.magic = ZMAGIC;
+    internal_a.magic = PE32PMAGIC;
 #endif /* IA64 */
 
 #if defined(SPARC)
@@ -4481,11 +4497,6 @@ coff_slurp_symbol_table (bfd * abfd)
 
            case C_MOS:         /* Member of structure.  */
            case C_EOS:         /* End of structure.  */
-#ifdef NOTDEF                  /* C_AUTOARG has the same value.  */
-#ifdef C_GLBLREG
-           case C_GLBLREG:     /* A29k-specific storage class.  */
-#endif
-#endif
            case C_REGPARM:     /* Register parameter.  */
            case C_REG:         /* register variable.  */
               /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
@@ -4830,7 +4841,7 @@ coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols)
   amt = (bfd_size_type) asect->reloc_count * sizeof (arelent);
   reloc_cache = bfd_alloc (abfd, amt);
 
-  if (reloc_cache == NULL)
+  if (reloc_cache == NULL || native_relocs == NULL)
     return FALSE;
 
   for (idx = 0; idx < asect->reloc_count; idx++)
This page took 0.028577 seconds and 4 git commands to generate.