Page 1 of 1
ld & Compiled asm?
Posted: Fri May 05, 2006 4:39 pm
by pieaholicx
Alright, I'm working on building my own OS, and this just happens to be the first time I've stepped out of the Visual Studio development box. I'm currently having an issue with ld. It works fine until I include my compiled assembly(named start.o, compiled with nasm). It claims to not recognize the file type. Any help?
Re:ld & Compiled asm?
Posted: Sat May 06, 2006 3:51 am
by guest
Check your file type in nasm (-f parameter IIRC), depending on what GCC/LD you are currently using (Cross Compiler with ELF, Cygwin, DJGPP) you will need a different format, ELF is "-f elf", Cygwin is "-f coff", DJGPP should be "-f coff" as well but I'm not sure if it works correctly.
Re:ld & Compiled asm?
Posted: Sun May 07, 2006 7:06 am
by pieaholicx
Alright, tried both of those, and neither worked. Here's the commands I'm issuing to build everything:
nasm -f aout -o start.o start.asm
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.c
ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o
Re:ld & Compiled asm?
Posted: Sun May 07, 2006 7:39 am
by YeXo
Are you using windows (cygwin or djgpp) or linux? Maybe try to get another version of nasm, that helped me when I had the same problems.
Re:ld & Compiled asm?
Posted: Fri May 12, 2006 6:35 pm
by pieaholicx
I'm using cygwin, and my nasm version is 0.98.35.
Re:ld & Compiled asm?
Posted: Fri May 12, 2006 8:02 pm
by guest
"nasm -f aout -o start.o start.asm" != "nasm -f elf -o start.o start.asm"
Re:ld & Compiled asm?
Posted: Sat May 13, 2006 2:52 pm
by pieaholicx
guest wrote:
"nasm -f aout -o start.o start.asm" != "nasm -f elf -o start.o start.asm"
Nobody ever said that I wanted an elf format...
Re:ld & Compiled asm?
Posted: Sat May 13, 2006 8:18 pm
by guest
Code: Select all
nasm -f coff -o start.o start.asm
nasm -f gnuwin32 -o start.o start.asm
Cygwin's GCC/BinUtils is a PE compiler (derivative of coff) therefore coff is the only thing it understands, a.out is an outdated UNIX format. (Elf was a mistype)