Re: Bad EXE format (error 193)

2007-10-05 Thread Lynn Winebarger
I forgot to cc the list, but the origin of the issue might be of
interest to someone.

On 10/5/07, Dave Korn <[EMAIL PROTECTED]> 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/



RE: Bad EXE format (error 193)

2007-10-05 Thread Dave Korn
On 05 October 2007 03:28, Lynn Winebarger wrote:

[  Cc'ing the mailing list back in. ]

> On 10/4/07, Lynn Winebarger <> wrote:
>> On 10/4/07, Dave Korn <> wrote:
>>>  Yes, why not; feel free to send them both to me, off list.  Can't promise
>>> I'll spot anything, but I'll take a look.  (My first WAG would be that the
>>> sassy assembler does something different from other w32 assemblers and
>>> that's where the trouble is coming from).
>> 
>>Many thanks, Dave, I will send them tonight.
>> 
> And they are attached.
> 
> Thanks!
> Lynn

  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

  To work this out, I looked at the headers to the binary you sent, using both
GNU (objdump -x) and MS (dumpbin /all).  Here's the output from editbin;
objdump shows all the same information in a slightly different form.

Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file larceny.bin

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
 14C machine (x86)
   8 number of sections
47059D7D time date stamp Fri Oct 05 03:12:13 2007
   2E000 file pointer to symbol table
 6EA number of symbols
  E0 size of optional header
 107 characteristics
   Relocations stripped
   Executable
   Line numbers stripped
   32 bit word machine

OPTIONAL HEADER VALUES
 10B magic # (PE32)
2.56 linker version
   23200 size of code
9800 size of initialized data
3000 size of uninitialized data
1000 entry point (00401000)
1000 base of code
   25000 base of data
  40 image base (0040 to 00435FFF)
1000 section alignment
 200 file alignment
4.00 operating system version
1.00 image version
4.00 subsystem version
   0 Win32 version
   36000 size of image
 2B8 size of headers
   44EB4 checksum
   3 subsystem (Windows CUI)
   0 DLL characteristics
  20 size of stack reserve
1000 size of stack commit
  10 size of heap reserve
1000 size of heap commit
   0 loader flags
  10 number of directories
   0 [   0] RVA [size] of Export Directory
   32000 [ 860] RVA [size] of Import Directory
   0 [   0] RVA [size] of Resource Directory
   0 [   0] RVA [size] of Exception Directory
   0 [   0] RVA [size] of Certificates Directory
   0 [   0] RVA [size] of Base Relocation Directory
   0 [   0] RVA [size] of Debug Directory
   0 [   0] RVA [size] of Architecture Directory
   0 [   0] RVA [size] of Global Pointer Directory
   0 [   0] RVA [size] of Thread Storage Directory
   0 [   0] RVA [size] of Load Configuration Directory
   0 [   0] RVA [size] of Bound Import Directory
   0 [   0] RVA [size] of Import Address Table Directory
   0 [   0] RVA [size] of Delay Import Directory
   0 [   0] RVA [size] of COM Descriptor Directory
   0 [   0] RVA [size] of Reserved Directory


  Looking at the headers, and comparing them to the output from a 'hello
world' C executable, one thing stood out:

 2B8 size of headers

  That's been 400 in every other program I've looked at.  It also meant
something to me, because I had tried experimentally attempting to relink the
larceny binary with the MS linker (link) just in case it could smooth out
something that was malformed, and it had mentioned 2B8 in the error message:


C:\>link larceny.bin /OUT:lar2.exe
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

larceny.bin : fatal error LNK1107: invalid or corrupt file: cannot read at
0x2B8


C:\> 

  So, what's at offset 0x2B8 in the larceny binary?  It turns out to be:


SECTION HEADER #1
.comment name
  1F virtual size
FFC0 virtual address (1 to 1001E)
 208 size of raw data
 2B8 file pointer to raw data (02B8 to 04BF)
   0 file pointer to relocation table
   0 file pointer to line numbers
   0 number of relocations
   0 number of line numbers
   0 flags

RAW DATA #1
  1: 00 54 68 65 20 4E 65 74 77 69 64 65 20 41 73 73 .The Netwide Ass
  10010: 65 6D 62 6C 65 72 20 30 2E 39 38 2E 33 39 00embler 0.98.39.


... some kind of comment/id section left behind by nasm.  Ok, fair enough, but
why would that 

RE: Bad EXE format (error 193)

2007-10-04 Thread Dave Korn
On 04 October 2007 16:04, Lynn Winebarger wrote:

> On 10/4/07, Dave Korn <[EMAIL PROTECTED]> wrote:
>> On 04 October 2007 15:26, Lynn Winebarger wrote:
>>> Thanks, Dave.  I did compile a hello-world.c program, and it ran, but
>>> I had also compiled PLT scheme v360 before (needed to bootstrap
>>> Larceny) and had run it without problem as well (I had thought this
>>> might be a permission issue, because what bash actually reports is
>>> "Access denied" - the underlying error took further investigation)
>> 
>>   Actually, I was trying to ask if you'd compiled a basic "helloworld" with
>> your new larceny compiler, or indeed if this example of yours is already a
>> very simple test program; i.e. is it only complex larceny executables that
>> don't work, or even the very simplest ones.
>> 
>I did not understand.  No, the larceny binary (runtime
> system/interpreter) won't load at all - it doesn't even make it to the
> entry point.

  Oh, my misunderstanding; I thought that we were talking about the compiled
executables /generated by/ the larceny compiler, rather than the actual
larceny compiler itself.

> I'm more than willing to send the "executable".  It
> might be something an expert could quickly spot.  Or the linker map
> output, if that would be useful.

  Yes, why not; feel free to send them both to me, off list.  Can't promise
I'll spot anything, but I'll take a look.  (My first WAG would be that the
sassy assembler does something different from other w32 assemblers and that's
where the trouble is coming from).

cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Re: Bad EXE format (error 193)

2007-10-04 Thread Lynn Winebarger
On 10/4/07, Lynn Winebarger <[EMAIL PROTECTED]> wrote:
> On 10/4/07, Dave Korn <[EMAIL PROTECTED]> wrote:
> > On 04 October 2007 15:26, Lynn Winebarger wrote:
> > > Thanks, Dave.  I did compile a hello-world.c program, and it ran, but
> > > I had also compiled PLT scheme v360 before (needed to bootstrap
> > > Larceny) and had run it without problem as well (I had thought this
> > > might be a permission issue, because what bash actually reports is
> > > "Access denied" - the underlying error took further investigation)
> >
> >   Actually, I was trying to ask if you'd compiled a basic "helloworld" with
> > your new larceny compiler, or indeed if this example of yours is already a
> > very simple test program; i.e. is it only complex larceny executables that
> > don't work, or even the very simplest ones.
> >
>I did not understand.  No, the larceny binary (runtime
> system/interpreter) won't load at all - it doesn't even make it to the
> entry point.  I'm more than willing to send the "executable".  It
> might be something an expert could quickly spot.  Or the linker map
> output, if that would be useful.

   Or, if someone knows of a program, or a pointer to what black magic
Windows does to determine that a PE file is "valid".  I have briefly
reviewed the PE documentation MS provides, but nothing has leaped out
at me (e.g. the flags on the sections appear consistent with their
specification).

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/



Re: Bad EXE format (error 193)

2007-10-04 Thread Lynn Winebarger
On 10/4/07, Dave Korn <[EMAIL PROTECTED]> wrote:
> On 04 October 2007 15:26, Lynn Winebarger wrote:
> > Thanks, Dave.  I did compile a hello-world.c program, and it ran, but
> > I had also compiled PLT scheme v360 before (needed to bootstrap
> > Larceny) and had run it without problem as well (I had thought this
> > might be a permission issue, because what bash actually reports is
> > "Access denied" - the underlying error took further investigation)
>
>   Actually, I was trying to ask if you'd compiled a basic "helloworld" with
> your new larceny compiler, or indeed if this example of yours is already a
> very simple test program; i.e. is it only complex larceny executables that
> don't work, or even the very simplest ones.
>
   I did not understand.  No, the larceny binary (runtime
system/interpreter) won't load at all - it doesn't even make it to the
entry point.  I'm more than willing to send the "executable".  It
might be something an expert could quickly spot.  Or the linker map
output, if that would be useful.

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/



RE: Bad EXE format (error 193)

2007-10-04 Thread Dave Korn
On 04 October 2007 15:26, Lynn Winebarger wrote:


>>> you see an error message along those lines, yes?  Hm.  Does it still
>>> happen if you compile the most basic sort of "hello world" program?
>> 
>> 
>>   It might also be informative to run "cygcheck " on your
>> compiled executable; that'll display the dependent DLLs for you.  A bit of
>> googling suggests that 193 can be caused by a corrupt/bogus executable, but
>> equally by a good executable thatt depends on a DLL which is faulty.
>> 
> 
> Thanks, Dave.  I did compile a hello-world.c program, and it ran, but
> I had also compiled PLT scheme v360 before (needed to bootstrap
> Larceny) and had run it without problem as well (I had thought this
> might be a permission issue, because what bash actually reports is
> "Access denied" - the underlying error took further investigation)

  Actually, I was trying to ask if you'd compiled a basic "helloworld" with
your new larceny compiler, or indeed if this example of yours is already a
very simple test program; i.e. is it only complex larceny executables that
don't work, or even the very simplest ones.

> $ cygcheck ./larcenybin.exe
> .\larcenybin.exe
>   C:\cygwin\bin\cygwin1.dll
> C:\WINDOWS\system32\ADVAPI32.DLL
>   C:\WINDOWS\system32\ntdll.dll
>   C:\WINDOWS\system32\KERNEL32.dll
>   C:\WINDOWS\system32\RPCRT4.dll

  Unfortunately that all looks completely correct, no clues there.

cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Re: Bad EXE format (error 193)

2007-10-04 Thread Lynn Winebarger
(Sorry for the formatting, I belatedly subscribed to the list and got
this as a thread digest)
> From: "Dave Korn" <[EMAIL PROTECTED]>
>
> > On 04 October 2007 14:56, Dave Korn wrote:
> >
> >>   We might be able to make guesses at what was wrong with the compiled
> >> program if you told us *in what way* it is "not close enough to satisfy
> >> Windows XP".
> >
> >   Ah.  And I just took a closer look at the subject line.  So I'm guessing
> > you see an error message along those lines, yes?  Hm.  Does it still happen
> > if you compile the most basic sort of "hello world" program?
>
>
>   It might also be informative to run "cygcheck " on your
> compiled executable; that'll display the dependent DLLs for you.  A bit of
> googling suggests that 193 can be caused by a corrupt/bogus executable, but
> equally by a good executable thatt depends on a DLL which is faulty.
>

Thanks, Dave.  I did compile a hello-world.c program, and it ran, but
I had also compiled PLT scheme v360 before (needed to bootstrap
Larceny) and had run it without problem as well (I had thought this
might be a permission issue, because what bash actually reports is
"Access denied" - the underlying error took further investigation).

$ cygcheck ./larcenybin.exe
.\larcenybin.exe
  C:\cygwin\bin\cygwin1.dll
C:\WINDOWS\system32\ADVAPI32.DLL
  C:\WINDOWS\system32\ntdll.dll
  C:\WINDOWS\system32\KERNEL32.dll
  C:\WINDOWS\system32\RPCRT4.dll


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/



RE: Bad EXE format (error 193)

2007-10-04 Thread Dave Korn
On 04 October 2007 14:59, Dave Korn wrote:

> On 04 October 2007 14:56, Dave Korn wrote:
> 
>> On 04 October 2007 14:21, Lynn Winebarger wrote:
>> 
>>>I am trying to get the Larceny Scheme compiler
>>> (http://www.ccs.neu.edu/home/will/Larceny/) to compile (and work)
>>> under the most recent stable Cygwin release.  While I have managed to
>>> get it to produce a file that very closely resembles a PE file, it
>>> apparently is not close enough to satisfy Windows XP Home Edition SP 2.
>>>Unfortunately, objdump and other file analyzers have no problem
>>> with the file, while none of the debuggers I tried had anything
>>> helpful to say about the problem.  I have compiled other things under
>>> Cygwin (PLT Scheme, for example) that not only produced an executable
>>> image but produced one Windows would actually run.  I have tried doing
>>> a diff against the headers between this and the Larceny image and
>>> cannot see a glaring error (but I am not an expert in either Windows
>>> executables or Larceny's source code).
>>> I cannot find anything helpful on this error in the mailing list
>>> archives.  Is there a tool that would identify the problem, or maybe a
>>> kind expert with some guidance on resolving this issue?
>> 
>>   We might be able to make guesses at what was wrong with the compiled
>> program if you told us *in what way* it is "not close enough to satisfy
>> Windows XP".
> 
>   Ah.  And I just took a closer look at the subject line.  So I'm guessing
> you see an error message along those lines, yes?  Hm.  Does it still happen
> if you compile the most basic sort of "hello world" program?  


  It might also be informative to run "cygcheck " on your
compiled executable; that'll display the dependent DLLs for you.  A bit of
googling suggests that 193 can be caused by a corrupt/bogus executable, but
equally by a good executable thatt depends on a DLL which is faulty.


cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



RE: Bad EXE format (error 193)

2007-10-04 Thread Dave Korn
On 04 October 2007 14:56, Dave Korn wrote:

> On 04 October 2007 14:21, Lynn Winebarger wrote:
> 
>>I am trying to get the Larceny Scheme compiler
>> (http://www.ccs.neu.edu/home/will/Larceny/) to compile (and work)
>> under the most recent stable Cygwin release.  While I have managed to
>> get it to produce a file that very closely resembles a PE file, it
>> apparently is not close enough to satisfy Windows XP Home Edition SP 2.
>>Unfortunately, objdump and other file analyzers have no problem
>> with the file, while none of the debuggers I tried had anything
>> helpful to say about the problem.  I have compiled other things under
>> Cygwin (PLT Scheme, for example) that not only produced an executable
>> image but produced one Windows would actually run.  I have tried doing
>> a diff against the headers between this and the Larceny image and
>> cannot see a glaring error (but I am not an expert in either Windows
>> executables or Larceny's source code).
>> I cannot find anything helpful on this error in the mailing list
>> archives.  Is there a tool that would identify the problem, or maybe a
>> kind expert with some guidance on resolving this issue?
> 
>   We might be able to make guesses at what was wrong with the compiled
> program if you told us *in what way* it is "not close enough to satisfy
> Windows XP".  

  Ah.  And I just took a closer look at the subject line.  So I'm guessing you
see an error message along those lines, yes?  Hm.  Does it still happen if you
compile the most basic sort of "hello world" program?

cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



RE: Bad EXE format (error 193)

2007-10-04 Thread Dave Korn
On 04 October 2007 14:21, Lynn Winebarger wrote:

>I am trying to get the Larceny Scheme compiler
> (http://www.ccs.neu.edu/home/will/Larceny/) to compile (and work)
> under the most recent stable Cygwin release.  While I have managed to
> get it to produce a file that very closely resembles a PE file, it
> apparently is not close enough to satisfy Windows XP Home Edition SP
> 2.
>Unfortunately, objdump and other file analyzers have no problem
> with the file, while none of the debuggers I tried had anything
> helpful to say about the problem.  I have compiled other things under
> Cygwin (PLT Scheme, for example) that not only produced an executable
> image but produced one Windows would actually run.  I have tried doing
> a diff against the headers between this and the Larceny image and
> cannot see a glaring error (but I am not an expert in either Windows
> executables or Larceny's source code).
> I cannot find anything helpful on this error in the mailing list
> archives.  Is there a tool that would identify the problem, or maybe a
> kind expert with some guidance on resolving this issue?

  We might be able to make guesses at what was wrong with the compiled program
if you told us *in what way* it is "not close enough to satisfy Windows XP".



cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Bad EXE format (error 193)

2007-10-04 Thread Lynn Winebarger
   I am trying to get the Larceny Scheme compiler
(http://www.ccs.neu.edu/home/will/Larceny/) to compile (and work)
under the most recent stable Cygwin release.  While I have managed to
get it to produce a file that very closely resembles a PE file, it
apparently is not close enough to satisfy Windows XP Home Edition SP
2.
   Unfortunately, objdump and other file analyzers have no problem
with the file, while none of the debuggers I tried had anything
helpful to say about the problem.  I have compiled other things under
Cygwin (PLT Scheme, for example) that not only produced an executable
image but produced one Windows would actually run.  I have tried doing
a diff against the headers between this and the Larceny image and
cannot see a glaring error (but I am not an expert in either Windows
executables or Larceny's source code).
I cannot find anything helpful on this error in the mailing list
archives.  Is there a tool that would identify the problem, or maybe a
kind expert with some guidance on resolving this issue?

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/