I am currently working on a kernel that can be built with both a GNU build system and an LLVM system. It currently works with GNU, but not LLVM. Here is my linker script
Code: Select all
ENTRY(_start)
SECTIONS
{
. = 0x100000;
.stivale2hdr : {
*(.stivale2hdr)
}
.text : ALIGN(4096) {
KEEP(*(.text*))
}
.data : ALIGN(4096) {
KEEP(*(.data*))
}
.rodata : ALIGN(4096) {
KEEP(*(.rodata*))
}
.bss : ALIGN(4096) {
KEEP(*(COMMON))
KEEP(*(.bss*))
}
/DISCARD/ : {
*(.comment)
*(.gnu*)
*(.note*)
*(.interp)
*(.dynsym)
*(.dynstr)
*(.dynamic)
*(.eh_frame*)
}
_end = .;
}
Code: Select all
// start-i386-mb2.s - contains start code for Multiboot 2 on i386
// Distributed with NexNix, licensed under the MIT license
// See LICENSE
.section .stivale2hdr
.align 8
header_start:
.quad 0 // Use ELF header entry
.long stack_top // Stack address
.long 0
.quad 0 // Flags
.long framebuffer_tag // Pointer to tags
.long 0
// Start of nexldr
.section .text
.global _start
_start:
cli
hlt
.section .data
framebuffer_tag:
.quad 0x3ecc1bc43d0f7971 // Framebuffer tag
.quad 0 // Only tag in list
.word 0 // Let bootloader pick values
.word 0
.word 0
.section .bss
.align 16
stack:
.skip 8192
stack_top:
But if I move the .stivale2hdr section after the .text section, .text get placed at the correct address, but everything else is offset from 0!
And here is my readelf output
https://gist.github.com/nexos-dev/a0797 ... 89e749f3c5
EDIT: I just looked at it again, and it is making a shared library! Why is that? My linker line is
Code: Select all
clang --target=i386-elf -fuse-ld=lld -nostdlib -Tarch/x86/i386-stivale2-link.ld arch/x86/start-i386-stivale2.o -o nldr,
nexos