.o not recognized

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
petrusss

.o not recognized

Post 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..
Tim

Re:.o not recognized

Post by Tim »

Try -f coff.
petrusss

Re:.o not recognized

Post by petrusss »

"ld: PE operation on non PE file."
That's what ld says.
Chris Giese

Re:.o not recognized

Post 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.
Tim

Re:.o not recognized

Post 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.
kaos

Re:.o not recognized

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:.o not recognized

Post 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?
Every good solution is obvious once you've found it.
Post Reply