Fixed linker and switched it to use clang directly instead of lld.

This commit is contained in:
neviyn 2017-10-21 17:13:40 +01:00
parent c05bcbec88
commit 7faa974542
2 changed files with 25 additions and 27 deletions

View File

@ -1,32 +1,30 @@
OUTPUT_FORMAT(elf32-i386)
ENTRY (start)
/* http://wiki.osdev.org/Bare_Bones#Linking_the_Kernel */
ENTRY(_start)
SECTIONS{
. = 0x00100000;
SECTIONS
{
. = 1M;
.text :{
code = .; _code = .; __code = .;
*(.text)
*(.rodata)
}
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data ALIGN (0x1000) : {
data = .; _data = .; __data = .;
*(.data)
start_ctors = .; *(.ctors) end_ctors = .;
start_dtors = .; *(.dtors) end_dtors = .;
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
.bss : {
sbss = .;
bss = .; _bss = .; __bss = .;
*(COMMON)
*(.bss)
ebss = .;
}
end = .; _end = .; __end = .;
}

View File

@ -1,7 +1,7 @@
all: kernel
kernel: bootloader
nim cc --cc:clang --clang.linkerexe=ld.lld --gc:none --deadCodeElim:on --cpu:i386 --os:standalone --passC:"-ffreestanding -nostdlib --target=i686-pc-none-elf -march=i686" --passL:"-m elf_i386 -T linker.ld boot.o" kernel.nim
nim cc --cc:clang --clang.linkerexe=clang --gc:none --deadCodeElim:on -d:StandaloneHeapSize=4096 --cpu:i386 --os:standalone --passC:"-ffreestanding -nostdlib --target=i686-pc-none-elf -march=i686" --passL:"-target i386 -nostdlib -T linker.ld boot.o" kernel.nim
bootloader:
nasm -felf32 boot.s -o boot.o