Code: Select all
bits 32 ; 32 bit code
extern kernel_entry
jmp Stage3 ; jump to entry point
%include "stdio.inc"
%include "Fat12.inc" ; FAT12 driver. Kinda :)
msg db 0x0A, 0x0A, " "
db 0x0A, 0x0A, " THEMOS Kernel Executing", 0x0A, 0
Stage3:
mov ax, 0x10 ; set data segments to data selector (0x10)
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 90000h ; stack begins from 90000h
call ClrScr32
mov ebx, msg
call Puts32
call kernel_entry
cli
hlt
Code: Select all
ENTRY("kernel_entry")
STARTUP(Stage3.o)
/* Tell where the various sections of the object files will be put in the final
kernel image. */
SECTIONS
{
/* Begin putting sections at 1 MiB, a conventional place for kernels to be
loaded at by the bootloader. */
. = 1M;
/* First put the multiboot header, as it is required to be put very early
early in the image or the bootloader won't recognize the file format.
Next we'll put the .text section. */
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
/* Read-only data. */
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
/* Read-write data (initialized) */
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
/* Read-write data (uninitialized) and stack */
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
*(.bootstrap_stack)
}
/* The compiler may produce other sections, by default it will put them in
a segment with the same name. Simply add stuff here as needed. */
}
Code: Select all
toolchain/gcc/bin/i686-pc-elf-ld -T linker.ld -o kernel.elf kernel.o
Stage3.o: In function `ClusterLBA':
stage3.asm:(.text+0x12e): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x134): relocation truncated to fit: R_386_16 against `.text'
Stage3.o: In function `LBACHS':
stage3.asm:(.text+0x13b): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x141): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x147): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x14b): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x14e): relocation truncated to fit: R_386_16 against `.text'
Stage3.o: In function `ReadSectors.SECTORLOOP':
stage3.asm:(.text+0x160): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x164): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x168): relocation truncated to fit: R_386_16 against `.text'
stage3.asm:(.text+0x16c): additional relocation overflows omitted from the output
EDIT: I was accidentally including 16 bit code, which resulted in those mysterious errors.