aboutsummaryrefslogtreecommitdiff
path: root/bfd/peicode.h
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/peicode.h
parent4cfec37b92f672f0b9d9cee334e83e201470654d (diff)
downloadgdb-05bf877ad11654a983d2ed5d31370e4469a657f0.zip
gdb-05bf877ad11654a983d2ed5d31370e4469a657f0.tar.gz
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/peicode.h')
-rw-r--r--bfd/peicode.h15
1 files changed, 15 insertions, 0 deletions
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)