Page 2 of 3
Re:Where to start ?
Posted: Sun Jan 01, 2006 9:45 am
by jason7007
Hi,
CjMovie, I did what you posted, but still not working.
ld complains: PE operation of non PE file.
What's wrong here?
Please help.
Re:Where to start ?
Posted: Sun Jan 01, 2006 9:52 am
by Phugoid
Then try
Code: Select all
nasm -f win32 -o start.o start.asm
It's a Cygwin system after all.
Re:Where to start ?
Posted: Sun Jan 01, 2006 10:24 am
by jason7007
Hi,
Still, ld not linking, complains PE operation on non PE file.
Re:Where to start ?
Posted: Sun Jan 01, 2006 10:45 am
by Phugoid
Have you tried -f gnuwin32? Which ones have you tried? Have you read the help output?
Re:Where to start ?
Posted: Sun Jan 01, 2006 11:16 am
by jason7007
Hi,
I tried these 2 methods:
1)nasmw -f win32 -o start.o start.asm
the above command will result to ld complaining of PE operation on non PE file
2)nasmw -f gnuwin32 -o start.o start.asm
the above command will result to namsw complaining of
unrecognized file output format
Re:Where to start ?
Posted: Sun Jan 01, 2006 11:28 am
by Phugoid
Your Cygwin should have nasm (no w). Try that.
Re:Where to start ?
Posted: Sun Jan 01, 2006 11:52 am
by JAAman
nasm is just another name for nasmw iirc (they both exist for backward compatability)
try reading the nasm help file -- it talks about two methods of assembling to PE, depending on which tools your using -- don't remember the details
the nasm help file is online: just google nasm help should find it (its my start page on my development system, but im not on it right now)
Re:Where to start ?
Posted: Sun Jan 01, 2006 11:58 am
by Phugoid
nasmw is just another name for nasm, but usually indicates a different kind of build, targeted for native Win32 and therefore lacking support for the output format jason7007 needs.
Re:Where to start ?
Posted: Sun Jan 01, 2006 12:38 pm
by jason7007
Hi,
I am using nasmw for windows because my os is windows XP,
is nasm for DOS good for windows xp?
Re:Where to start ?
Posted: Sun Jan 01, 2006 12:41 pm
by Phugoid
Your OS is effectively Cygwin, so try to use the nasm that comes with it (hint: look in cygwin/bin). It should support the gnuwin32 format. If you don't have it, use Cygwin's setup.exe program to install it.
Re:Where to start ?
Posted: Sun Jan 01, 2006 1:28 pm
by jason7007
Hi,
I changed from nasmw to nasm. And nasm.exe is already in cygwin/bin. But to no avail.
The same complain of nasm or the ld.
Re:Where to start ?
Posted: Sun Jan 01, 2006 1:40 pm
by Phugoid
Your Cygwin-provided NASM does not support gnuwin32? Are you sure you are not using some other executable named nasm.exe?
Code: Select all
$ nasm -hf
...
gnuwin32 GNU MinGW32/Cygwin Win32 (i386) object files
...
Re:Where to start ?
Posted: Sun Jan 01, 2006 11:27 pm
by jason7007
Hi,
I am 100% sure , I have only one nasm.exe, and that is in Cygwin\bin
Re:Where to start ?
Posted: Mon Jan 02, 2006 12:24 pm
by Phugoid
Ah, I am sorry for not trying this earlier.
I inferred from your posts that you are using the "stock" tools provided with Cygwin, and not a cross-compiler. These tools are targeted for i386-pe and not aout, as the example in Bran's tutorial is. Here is what you need to do to start.asm and the linker script to make them PE-compatible:
In start.asm, insert the line
immediately after
In the linker script, change
to
And use
Code: Select all
nasm -f win32 -o start.o start.asm
to assemble; use the same command as before to link.
I hope this helps!
Re:Where to start ?
Posted: Mon Jan 02, 2006 12:59 pm
by jason7007
Hi Phugoid,
I followed all steps that you posted, but a different problem came up.
Here are the messages from ld
main.o:main.c:(.text+0x9d):undefined reference to '_alloca'
main.o:main.c:(.text+0xa2):undefined reference to '_main'
Thank you anyway for your time.