Page 1 of 1

.o not recognized

Posted: Sat Oct 25, 2003 8:24 am
by petrusss
I've just installed Mingw, but ld doesn't recognize the .o fileformat =/
The .o is assembled with nasmw, -f aout.
I can't use any PE's, so, what to do?
I don't want to use cygwin..

Re:.o not recognized

Posted: Sat Oct 25, 2003 10:58 am
by Tim
Try -f coff.

Re:.o not recognized

Posted: Sat Oct 25, 2003 8:34 pm
by petrusss
"ld: PE operation on non PE file."
That's what ld says.

Re:.o not recognized

Posted: Sat Oct 25, 2003 9:39 pm
by Chris Giese
Relocatable (.o or .obj) files can be in different formats, depending on the tool chain. For MinGW, these files are Win32 PE COFF. This is the only format the MinGW linker recognizes.

Try "nasm -f win32 ...". If you're using the "aout" format because you need to mix 16- and 32-bit code, you're out of luck -- you must separate the 16- and 32-bit parts.

DON'T use "nasm -f coff ...". Though relocatable files in Win32 PE COFF format and regular (DJGPP) COFF format look identical, they're not. The relocations work differently. The linker will let you link files in the two formats, but the resulting executable won't work properly.

Re:.o not recognized

Posted: Sun Oct 26, 2003 5:34 am
by Tim
Oops, that should have been -f win32. If you're trying to get ld to link to something other than PE, you're out of luck. If you don't want to use PE for your kernel, you should link to PE anyway (i.e. don't override ld's output format), then use objcopy to convert to the format you want.

Re:.o not recognized

Posted: Thu Oct 30, 2003 2:16 am
by kaos
Tim Robinson wrote: If you're trying to get ld to link to something other than PE, you're out of luck. If you don't want to use PE for your kernel, you should link to PE anyway (i.e. don't override ld's output format), then use objcopy to convert to the format you want.
You will probably want to recompile binutils to work with other object file formats. Objcopy might not be able to work with the format that you want before recompiling.

Re:.o not recognized

Posted: Thu Oct 30, 2003 2:20 am
by Solar
What I'd be interested in would be a different part of that posting:
petrusss wrote: I don't want to use cygwin..
Would you mind sharing your reason?