error: invalid arch-dependent ELF magic when using grub
Posted: Sat Jun 18, 2022 10:55 am
i was trying to follow the bare bones tutorial with c++
i think the problem might be with my makefile so im gonna put it here
i tried copying the boot.s code from the wiki page but it still keeps giving me the error
it might also be the c++ code so im gonna put that there too
the kernel.hpp file is empty apart from an include guard and the comment at the start
i think the problem might be with my makefile so im gonna put it here
Code: Select all
C_SOURCES = $(wildcard kernel/*.cpp libk/*.cpp libc/*.cpp)
HEADERS = $(wildcard kernel/*.hpp libk/*.hpp libc/*.hpp)
OBJ = ${C_SOURCES:.cpp=.o}
CC = i686-elf-g++
GDB = i686-elf-gdb
CFLAGS = -g -m32 -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \
-Wall -Wextra -fcommon
run: iota.iso
qemu-system-i386 -cdrom iota.iso
iota.iso: kernel.bin
cp kernel.bin isodir/boot/kernel.bin
grub-mkrescue -o iota.iso isodir
kernel.bin: boot.o ${OBJ}
i686-elf-ld -o $@ -T linker.ld $^ --oformat binary
boot.o: boot.s
i686-elf-as boot.s -o boot.o
%.o: %.cpp ${HEADERS}
${CC} ${CFLAGS} -ffreestanding -c $< -o $@
clean:
rm ${OBJ} iota.iso kernel.bin
it might also be the c++ code so im gonna put that there too
Code: Select all
//
// kernel.cpp
// iota
//
// Created by Anthony Valdes on 2022-06-17.
//
#include "kernel.hpp"
extern "C" void kmain(void) {
}