ld & Compiled asm?

Programming, for all ages and all languages.
Post Reply
pieaholicx

ld & Compiled asm?

Post 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?
guest

Re:ld & Compiled asm?

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

Re:ld & Compiled asm?

Post 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
YeXo

Re:ld & Compiled asm?

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

Re:ld & Compiled asm?

Post by pieaholicx »

I'm using cygwin, and my nasm version is 0.98.35.
guest

Re:ld & Compiled asm?

Post by guest »

"nasm -f aout -o start.o start.asm" != "nasm -f elf -o start.o start.asm"
pieaholicx

Re:ld & Compiled asm?

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

Re:ld & Compiled asm?

Post 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)
Post Reply