Code: Select all
kernel.o: file not recognized: file format not recognized
If I do "readelf -h kernel.o" I get
Code: Select all
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 432 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 9
Section header string table index: 8
Here is my full makefile. I am well aware that it's not a shining example of best practice and I don't intend for it to look like this forever.
Code: Select all
export PATH:=$(HOME)/opt/cross/bin/:$(PATH)
ASM=nasm
CC=i686-elf-gcc
LD=i686-elf-ld
CFLAGS=-std=gnu99 -ffreestanding -O2 -Wall -Wextra
LINKFLAGS=-ffreestanding -O2 -nostdlib -lgcc
ASMFLAGS=-f bin
.PHONY: all clean
all: bootloader.flp
bootloader.flp: bootsec.bin stageone.bin
cat bootsec.bin stageone.bin > bootloader.flp
bootsec.bin:
$(ASM) bootsec.asm $(ASMFLAGS) -o bootsec.bin
stageone.bin: stageone.o kernel.o
$(CC) -T linker.ld -o stageone.bin $(LINKFLAGS) stageone.o kernel.o
stageone.o:
$(ASM) stageone.asm -f elf -o stageone.o
kernel.o:
$(CC) -c kernel.c -o kernel.o $(CFLAGS)
clean:
rm -f bootloader.flp bootsec.bin stageone.bin stageone.o kernel.o