(Generating happy PE images with CYGWIN)
Does anyone understand the different "bfd"s and what is expected in
the PE image well enough to give me some pointers on how to have
the cygwin tools emit what wine is expecting in pe_image.c where
you get the "no relocation records present (stripped during link)"
message? I want to be able to do some debugging on .EXE files without
stooping to obtaining a windows box - I successfully do rudimentary
testing with wine, but I can't run full regression scripts because, e.g.,
I can't run "sh" under wine.
To head off the "Why?" comments: Yes, this makes sense when I have
a problem with my programs that shows up identically between
WIN32 and WINE and doesn't show up native (FreeBSD in my case).
I'm assuming that if I can get the relocation info left in with
a fully linked output wine will handle things.
Here's what I find. Here is the output type and a bit of the name list
for the image which runs fine except
for the missing reloc (linking with "-oformat pei-i386"):
> rt% i586-cygwin32-objdump --file-headers sh.exe
>
> sh.exe: file format pei-i386
> architecture: i386, flags 0x00000132:
> EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
> start address 0x00401000
>
> rt%
Here is my test sh script. You'll see the builtins work fine.
> pwd
> echo 'hello world'
> ls -l
The output, less a few unrelated FIXME messages:
> rt% wine 'sh f:foo.sh'
> //F/dufault
> hello world
> fixme:win32:PE_LoadImage FATAL: Need to relocate
>G:\cygb20.1\i586-cygwin32\bin\sh.exe, but no relocation records present (stripped
>during link). Try to run that file directly !
> f:foo.sh: Cannot fork
Linking with "-relocateable -oformat pei-i386":
> rt% i586-cygwin32-objdump --file-headers sh.exe
>
> sh.exe: file format pe-i386
> architecture: i386, flags 0x00000031:
> HAS_RELOC, HAS_SYMS, HAS_LOCALS
> start address 0x00000000
However, the resulting file isn't executeable, and it hasn't
been relocated at all judging from running "nm" on it. Note
that the start address is still 0. Wine won't run this program. Leaving
it not-executeable and running it wine will exit with no messages,
setting it executeable wine will run it as a shell script or something.
I've tried all types of linker flags and I've decided I can't generate
an acceptable file without changing ld. I guess my question is:
do I need to get ld to generate the same executeable as it does
without the "-relocateable" flag yet include the exact same relocation
information as it has with the "-relocateable" flag? Or am I barking
up the wrong tree?
Peter
--
Peter Dufault ([EMAIL PROTECTED]) Realtime development, Machine control,
HD Associates, Inc. Fail-Safe systems, Agency approval