public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: DJ Delorie <dj@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: [patch] coff-stgo32: Fix false format match
Date: Wed, 20 Jul 2011 19:24:00 -0000	[thread overview]
Message-ID: <20110720185758.GA7995@host1.jankratochvil.net> (raw)
In-Reply-To: <201107201826.p6KIQpo2000573@greed.delorie.com>

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.


Thanks,
Jan


bfd/
2011-07-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix false coff-go32-exe matches.
	* coff-i386.c (TARGET_SYM) <match_priority>: Use TARGET_MATCH_PRIORITY
	if available.
	* coff-stgo32.c (TARGET_MATCH_PRIORITY): New defintion.

--- a/bfd/coff-i386.c
+++ b/bfd/coff-i386.c
@@ -661,7 +661,11 @@ const bfd_target
 #endif
   '/',				/* ar_pad_char */
   15,				/* ar_max_namelen */
-  0,				/* match priority.  */
+#ifdef TARGET_MATCH_PRIORITY
+  TARGET_MATCH_PRIORITY,	/* match priority */
+#else
+  0,				/* match priority */
+#endif
 
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -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
+
 #include "coff-i386.c"
 
 /* This macro is used, because I cannot assume the endianness of the

  reply	other threads:[~2011-07-20 18:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 15:55 Jan Kratochvil
2011-07-20 19:10 ` DJ Delorie
2011-07-20 19:24   ` Jan Kratochvil [this message]
2011-07-22 11:21     ` DJ Delorie
2011-07-22 12:49       ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110720185758.GA7995@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=dj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).