Bad EXE format (error 193)

Lynn Winebarger owinebar@gmail.com
Sat Oct 6 00:35:00 GMT 2007


I forgot to cc the list, but the origin of the issue might be of
interest to someone.

On 10/5/07, Dave Korn <dave.korn@artimi.com> wrote:
>   Well, this was a weird one.  I think the underlying problem must be a bug in
> larceny's final link stage during the build.  First, this command made your
> binary executable for me:
>
>     objcopy -R .comment larceny.bin larceny2.exe
>
> [Detailed analysis omitted]
>   So, the file is regarded as malformed by the loader because it contains a
> section that isn't correctly aligned to the file alignment.  I don't know how
> it got that way, but it's clearly inconsistent.  It might be that the section
> was supposed to have EXCLUDE or some other flag that would have made the
> loader not care, I don't know, but since it's just a comment section,
> discarding it with objdump -R does the job nicely.

    Thanks, Dave!  With that information, I have tracked down the
problem.  The original Makefile uses "nasm -o foo.o foo.asm -f elf
-g".  I had subsequently changed this to "-f gnuwin32" (no -g),  but
the "make clean" did not actually erase that particular object file.
     The comment only appears in files made with -f elf and -g (at
least, it doesn't appear with "-f gnuwin32 -g", or "-f win32 -g").
The section has alignment 2**0, compared to 2**2 of every other
section.
    I'm surprised ld (or collect2, I don't know how different they
are) did not at least complain about this if it wasn't willing to pad
the section.

Thanks,

Lynn

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list