X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B?a=blobdiff_plain;f=kernel%2Flinker.ld;h=a6fb8e48ed2d2289fde99b19e8bb976ac75d004c;hb=da4e7bf5dd2b9448b638255a20ee503b0641e495;hp=d68e9f2c96af541f9042df444d10f7803ff1e7fb;hpb=3d58037b465f917b19b0f786c334ed70e1065857;p=nameless-os.git diff --git a/kernel/linker.ld b/kernel/linker.ld index d68e9f2..a6fb8e4 100644 --- a/kernel/linker.ld +++ b/kernel/linker.ld @@ -1,11 +1,43 @@ ENTRY(_start) -OUTPUT_FORMAT(binary) SECTIONS { - . = 0x1000; + . = 0xc0000000; + __KERNEL_BASE__ = .; - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss) } + .text : AT(ADDR(.text) - 0xbff00000) ALIGN(4K) { + __TEXT_BASE__ = .; + kernel/entry.o (.text) + *(.text) + __TEXT_END__ = .; + } + .rodata : AT(ADDR(.rodata) - 0xbff00000) ALIGN(4K) { + __RODATA_BASE__ = .; + *(.rodata) + __RODATA_END__ = .; + } + + /* .rodata is put after .text so that the read-only entry in the program + * header covers .rodata as well. When .rodata is after .data, that entry + * only covers .text, leaving .rodata in the writable program header + * entry. The problem with this approach is that the program header + * entry where .text and .rodata are is marked as executable, which + * would mean that .rodata should be executable too, but that doesn't + * matter yet because we (currently) assume that the NX bit is not + * supported anyway. */ + + .data : AT(ADDR(.data) - 0xbff00000) ALIGN(4K) { + __DATA_BASE__ = .; + *(.data) + __DATA_END__ = .; + } + .bss : AT(ADDR(.bss) - 0xbff00000) ALIGN(4K) { + __BSS_BASE__ = .; + *(.bss) + /* Reserving 16KiB for the stack. A __STACK_TOP__ is not really + * needed (yet). */ + . += 16K; + __STACK_BOTTOM__ = .; + __BSS_END__ = .; + } }