aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1999-09-11 22:41:54 +0000
committerIan Lance Taylor <ian@airs.com>1999-09-11 22:41:54 +0000
commit05bf877ad11654a983d2ed5d31370e4469a657f0 (patch)
treef30a585c59f9991f439163e37eac2e8b934c26ae /bfd
parent4cfec37b92f672f0b9d9cee334e83e201470654d (diff)
downloadfsf-binutils-gdb-05bf877ad11654a983d2ed5d31370e4469a657f0.zip
fsf-binutils-gdb-05bf877ad11654a983d2ed5d31370e4469a657f0.tar.gz
fsf-binutils-gdb-05bf877ad11654a983d2ed5d31370e4469a657f0.tar.bz2
1999-09-11 Donn Terry <donn@interix.com>
* peicode.h (coff_swap_filehdr_in): Check the NT executable magic number if COFF_IMAGE_WITH_PE.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog3
-rw-r--r--bfd/peicode.h15
2 files changed, 18 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 26ffe3d..e5f7383 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -7,6 +7,9 @@
1999-09-11 Donn Terry <donn@interix.com>
+ * peicode.h (coff_swap_filehdr_in): Check the NT executable magic
+ number if COFF_IMAGE_WITH_PE.
+
* coffcode.h (coff_mkobject_hook): If COFF_WITH_PE, set HAS_DEBUG
to the reverse of IMAGE_FILE_DEBUG_STRIPPED.
(coff_write_object_contents): Set IMAGE_FILE_DEBUG_STRIPPED if
diff --git a/bfd/peicode.h b/bfd/peicode.h
index e7bab84..2a19565 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -295,6 +295,21 @@ coff_swap_filehdr_in (abfd, src, dst)
filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
+#ifdef COFF_IMAGE_WITH_PE
+ /* There are really two magic numbers involved; the magic number
+ that says this is a NT executable (PEI) and the magic number that
+ determines the architecture. The former is DOSMAGIC, stored in
+ the e_magic field. The latter is stored in the f_magic field.
+ If the NT magic number isn't valid, the architecture magic number
+ could be mimicked by some other field (specifically, the number
+ of relocs in section 3). Since this routine can only be called
+ correctly for a PEI file, check the e_magic number here, and, if
+ it doesn't match, clobber the f_magic number so that we don't get
+ a false match. */
+ if (bfd_h_get_16 (abfd, (bfd_byte *) filehdr_src->e_magic) != DOSMAGIC)
+ filehdr_dst->f_magic = -1;
+#endif
+
/* Other people's tools sometimes generate headers with an nsyms but
a zero symptr. */
if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0)