This is the mail archive of the
mailing list for the binutils project.
Re: [patch] coff-stgo32: Fix false format match
On Wed, 20 Jul 2011 20:26:51 +0200, DJ Delorie wrote:
> GO32 binaries need not have the stub on them, so you have to check for
> MZ as well as a standard COFF magic number at offset zero.
I have modified only coff-stgo32.c ("coff-go32-exe") which seems to always
offset everything of COFF by GO32_STUBSIZE.
There is also coff-go32.c ("coff-go32") but I haven't touched that one.
My former patch for coff-go32-exe does MZ check && coff magic check.
The FSF binutils HEAD code does coff magic check.
Your proposed IIUC MZ check || coff magic check
is not useful because the coff magic check itself has the false positives.
Still I do not know whether there isn't in use some alternative env(GO32STUB)
for a .com file - where for .com there would be no 'MZ' signature.
Alternatively proposing the patch below.
No regressions x86_64-fedora16pre-linux-gnu --target=i386-unknown-go32.
2011-07-20 Jan Kratochvil <email@example.com>
Fix false coff-go32-exe matches.
* coff-i386.c (TARGET_SYM) <match_priority>: Use TARGET_MATCH_PRIORITY
* coff-stgo32.c (TARGET_MATCH_PRIORITY): New defintion.
@@ -661,7 +661,11 @@ const bfd_target
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- 0, /* match priority. */
+ TARGET_MATCH_PRIORITY, /* match priority */
+ 0, /* match priority */
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
@@ -100,6 +100,10 @@ static bfd_boolean
#define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
+/* Two bytes of magic are too fragile when matched at GO32_STUBSIZE offset
+ inside executable. */
+#define TARGET_MATCH_PRIORITY 10
/* This macro is used, because I cannot assume the endianness of the