So, I'm linking my second stage bootloader with a ld script
Code: Select all
ENTRY(ssblstart)
SECTIONS
{
.text 0x500 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Code: Select all
OBJDIR = ../../build/objects/bootloader
BINDIR = ../../build/bin
CC = gcc
LD=/usr/local/cross/bin/x86_64-elf-ld
ASM = nasm
all: boot
boot: bootstart
bootstart: bootstart.s ssbootloader.s
@$(ASM) bootstart.s -f bin -o $(BINDIR)/bootstart.img
@$(ASM) ssbootloader.s -f elf -o $(OBJDIR)/ssbootloader.o
Code: Select all
LD=/usr/local/cross/bin/x86_64-elf-ld
SRC=../src
#bootstart.img=512 bytes
#ssbootloader.img=10kilobytes
all: bootloader bin/ssbootloader.img bin/bootstart.img
@dd if=/dev/zero of=CUBE.iso bs=1024 count=1440 seek=0 skip=0
@dd conv=notrunc if=bin/bootstart.img of=CUBE.iso
@dd if=bin/ssbootloader.img of=CUBE.iso seek=1 skip=0 bs=512 count=10 conv=notrunc
bootloader: objects/bootloader/ssbootloader.o $(SRC)/bootloader/ssblinker.ld
@$(LD) -T $(SRC)/bootloader/ssblinker.ld -o bin/ssbootloader.img objects/bootloader/ssbootloader.o
#-m elf_i386 --oformat=elf32-i386
clean:
@rm bin/*.img
@rm CUBE.iso
@rm objects/bootloader/*.o
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386)
TARGET(elf32-i386)
to the top of the linker script fixes it. However, it also makes it so the object code produced isn't properly processed into a binary. How would I go about fixing this?