diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2011-07-20 19:22:29 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2011-07-20 19:22:29 +0000 |
commit | f5e3c232f56d01124c380f1983bf57542785219b (patch) | |
tree | 3c8e94bd2af4d31d602e1e7512d8ffe2cccaaac9 /bfd/coff-stgo32.c | |
parent | 9ae423b6d58e0deb120980ee82f18b8a5fefe29f (diff) | |
download | binutils-redhat-f5e3c232f56d01124c380f1983bf57542785219b.tar.gz |
bfd/
Fix false coff-go32-exe matches.
* coff-i386.c (TARGET_SYM) <_bfd_check_format>: Conditionally use
COFF_CHECK_FORMAT.
* coff-stgo32.c (go32_check_format): New forward declaration.
(COFF_CHECK_FORMAT): New defintion.
(go32_check_format): New function.
Diffstat (limited to 'bfd/coff-stgo32.c')
-rw-r--r-- | bfd/coff-stgo32.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index e0038cc94a..c10194e6be 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -95,6 +95,10 @@ create_go32_stub PARAMS ((bfd *)); #define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre #define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post +static const bfd_target *go32_check_format (bfd *abfd); + +#define COFF_CHECK_FORMAT go32_check_format + static bfd_boolean go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); @@ -414,3 +418,23 @@ go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd) return TRUE; } + +/* coff_object_p only checks 2 bytes F_MAGIC at GO32_STUBSIZE inside the file + which is too fragile. */ + +static const bfd_target * +go32_check_format (bfd *abfd) +{ + char mz[2]; + + if (bfd_bread (mz, 2, abfd) != 2 || mz[0] != 'M' || mz[1] != 'Z') + { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } + + if (bfd_seek (abfd, 0, SEEK_SET) != 0) + return NULL; + + return coff_object_p (abfd); +} |