Could anyone help me on why ld.lld is telling me:
clang -ffreestanding -mno-red-zone -m32 -c kernel/main.cpp -o kernel.o
ld.lld -m elf_i386 -T kernel/linker.ld -o kernel.bin kernel.o
ld.lld: error: kernel.o: unknown file type
make: *** [Makefile:13: kernel.bin] Error 1
I'm trying to compile kernel/main.cpp, link it with kernel/linker.ld, and then produce a .bin of the kernel, but this error I've been trying to debug for an hour is keeping me from doing that
I've tried google, couldn't find anything
This is my main.cpp file
extern "C" void kernelMain() {
const char* hello = "Hello world!";
char* vga = (char*)0xb8000;
for(int i = 0; i < 11; i++) {
vga[i*2] = hello[i];
vga[i*2+1] = 0x0F;
}
}
extern "C" void _start() {
kernelMain();
while(1) {}
}
My linker.ld file:
ENTRY(_start)
SECTIONS {
. = 0x1000;
.text : {
*(.text)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
}
And then my makefile:
NASM=nasm
QEMU=qemu-system-x86_64
CC=clang
LD=ld.lld
all: boot.bin kernel.bin
boot.bin: boot/boot.asm
$(NASM) -f bin -o $@ $<
kernel.bin: kernel/main.cpp kernel/linker.ld
$(CC) -ffreestanding -mno-red-zone -m32 -c $< -o kernel.o
$(LD) -T kernel/linker.ld -o $@ kernel.o
run: boot.bin kernel.bin
$(QEMU) -drive format=raw,file=$<
clean:
rm -f boot.bin kernel.bin kernel.o
Any help is appreaciated