X-Git-Url: http://git.dujemihanovic.xyz/projects?a=blobdiff_plain;f=kernel%2Flinker.ld;h=645a82421029a638d8ea58a86e8282852af09936;hb=94770e6354578485b2aed68dcc3064e5d6862645;hp=59d0381af92cf1bf95859357d31b9e2d63b6a11f;hpb=1d0592f3c62d45b1fc23e807bf8cc2274496a4f5;p=nameless-os.git diff --git a/kernel/linker.ld b/kernel/linker.ld index 59d0381..645a824 100644 --- a/kernel/linker.ld +++ b/kernel/linker.ld @@ -4,8 +4,29 @@ OUTPUT_FORMAT(binary) SECTIONS { . = 0x100000; + __KERNEL_BASE__ = .; - .text : ALIGN(0x1000) { *(.text) } - .data : ALIGN(0x1000) { *(.data) } - .bss : ALIGN(0x1000) { *(.bss) } + .text : ALIGN(4K) { + kernel/entry.o (.text) + *(.text) + } + .rodata : ALIGN(4K) { *(.rodata) } + + /* .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 : ALIGN(4K) { *(.data) } + .bss : ALIGN(4K) { + *(.bss) + /* Reserving 16KiB for the stack. A __STACK_TOP__ is not really + * needed (yet). */ + . += 16K; + __STACK_BOTTOM__ = .; + } }