* coff-i386.c (coff_i386_reloc): Don't dump core if output_bfd is
[binutils-gdb.git] / bfd / coff-i386.c
index d35e2cad40a05cb3dbf7b00f1c3c5c69d5b81cec..7d4ab5ae3985d12a008baa45bd4617cd80dcc804 100644 (file)
@@ -129,7 +129,9 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
 
 #ifdef COFF_WITH_PE
   /* FIXME: How should this case be handled?  */
-  if (reloc_entry->howto->type == R_IMAGEBASE)
+  if (reloc_entry->howto->type == R_IMAGEBASE
+      && output_bfd != NULL
+      && bfd_get_flavour(output_bfd) == bfd_target_coff_flavour)
     diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
 #endif
 
@@ -489,7 +491,9 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
        *addendp -= sym->n_value;
     }
 
-  if (rel->r_type == R_IMAGEBASE)
+  if (rel->r_type == R_IMAGEBASE
+      && (bfd_get_flavour(sec->output_section->owner)
+         == bfd_target_coff_flavour))
     {
       *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
     }