ld does not recognize nasm output format

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
Freanan

ld does not recognize nasm output format

Post by Freanan »

I want to use a start-routine in assembler to set up idt and jump to the c-main-function.
I use

Code: Select all

nasmw -o start.o start.asm -f aout
to assemble the startup stuff (also tried -f obj instead of aout) and

Code: Select all

gcc -c -ffreestanding -o kernel.o kernel.c
to compile the main file.
Both things worked, but linking it together with

Code: Select all

ld -Ttext 0x1000 --oformat binary -o kernel.bin start.o kernel.o 
does not work, instead i get a message, that the format of start.o is not recognized.

But i remember that this worked back when i had a linux system...
What do i have to do to link my kernel?
Do i have to install linux again... or is there any possibility to link it under windows?
Thanks.
pini

Re:ld does not recognize nasm output format

Post by pini »

I'm compiling asm code to elf with nasm, and ld never complained about that.
K.J.

Re:ld does not recognize nasm output format

Post by K.J. »

nasmw -o start.o start.asm -f aout
Try:
nasmw -o start.o -f aout start.asm

K.J.
Freanan

Re:ld does not recognize nasm output format

Post by Freanan »

K.J. wrote:
nasmw -o start.o start.asm -f aout
Try:
nasmw -o start.o -f aout start.asm

K.J.
Tried it, but it did not make any diference.

Since i have a new DevC++ with new gcc and ld, i cannot even build .bins from gcc-only-kernel files!
I always get 'PE operation in non-PE file'.
So i can only code in assembler until i get linux again >:(!
Therx

Re:ld does not recognize nasm output format

Post by Therx »

I use NASM under windows with ld and it works but instead of:-

-f aout

I use:-

-f coff

Try that

Pete
nwp
Posts: 4
Joined: Tue Feb 08, 2011 4:44 am

Re: ld does not recognize nasm output format

Post by nwp »

I have the same problem. Here are some nasm options and the corresponding ld errors:
-f aout/rdf -> file format not recognized
-f coff/win32/win64 -> error: COFF format does not support any special symbol types
-f elf/elf32/elf64 -> cannot perform PE operations on non PE output file
-f obj -> error: OBJ supports no special symbol features for this symbol type
-f ieee -> error: unrecognised symbol type `function'
-f as86 -> error: as86 format does not support any special symbol types

Somehow I run out of nasm output formats.
The whole thing is supposed to run on Win7x64 using minGW.
Previously I used djgpp, which is a gcc port for Windows for DOS programs and therefore could read the coff format. Unfortunately it also consists of 16bit programs that do not run on 64bit Windows.

It would be nice if someone knows of a C/C++-Compiler with a Linker that can read some format that nasm can produce.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ld does not recognize nasm output format

Post by Combuster »

Your exact error message is in the FAQ. Please search before posting.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: ld does not recognize nasm output format

Post by Solar »

nwp wrote:The whole thing is supposed to run on Win7x64 using minGW.
Previously I used djgpp...
The Wiki on MinGW:
Really, you're advised not to use MinGW for OSDeving, but instead to use Cygwin.
The Wiki on DJGPP:
While DJGPP has been widely used for OS development in the past, it's close connection to MS-DOS and compatibility problems with Windows XP have caused most Windows users to shift to Cygwin or MinGW. DJGPP must be considered obsolete by now.
It would be nice if someone knows of a C/C++-Compiler with a Linker that can read some format that nasm can produce.
The Wiki knows, and it's called Cygwin and GCC Cross-Compiler.

A hint: Cygwin provides a very useful utility called 'file'. When your toolchain gives you problems, call 'file <filename>' to get information of what format a given file actually is in.
Every good solution is obvious once you've found it.
Post Reply