This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Patch to avoid core dumps when linking pe-i386 into non-PE
- To: binutils at sources dot redhat dot com
- Subject: Patch to avoid core dumps when linking pe-i386 into non-PE
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 8 May 2001 10:45:12 -0700
I just checked in the appended patch to avoid core dumps when linking
pe-i386 into non-PE files.
I doubt the result links correctly. But presumably a patch like this
would be part of any complete fix.
Ian
2001-05-08 Ian Lance Taylor <ian@zembu.com>
* coff-i386.c (coff_i386_reloc): Don't dump core if output_bfd is
NULL or is not COFF.
(coff_i386_rtype_to_howto): Don't dump core if output section
owner is not COFF.
Index: coff-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-i386.c,v
retrieving revision 1.13
diff -u -p -r1.13 coff-i386.c
--- coff-i386.c 2001/04/13 22:42:48 1.13
+++ coff-i386.c 2001/05/08 17:41:27
@@ -129,7 +129,9 @@ coff_i386_reloc (abfd, reloc_entry, symb
#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
*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;
}