]> git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/linker.ld
Enable paging in bootloader
[nameless-os.git] / kernel / linker.ld
1 ENTRY(_start)
2 OUTPUT_FORMAT(binary)
3
4 SECTIONS
5 {
6 . = 0xc0000000;
7 __KERNEL_BASE__ = .;
8
9 .text : AT(ADDR(.text) - 0xbf000000) ALIGN(4K) {
10 __TEXT_BASE__ = .;
11 kernel/entry.o (.text)
12 *(.text)
13 __TEXT_END__ = .;
14 }
15 .rodata : AT(ADDR(.rodata) - 0xbf000000) ALIGN(4K) {
16 __RODATA_BASE__ = .;
17 *(.rodata)
18 __RODATA_END__ = .;
19 }
20
21 /* .rodata is put after .text so that the read-only entry in the program
22 * header covers .rodata as well. When .rodata is after .data, that entry
23 * only covers .text, leaving .rodata in the writable program header
24 * entry. The problem with this approach is that the program header
25 * entry where .text and .rodata are is marked as executable, which
26 * would mean that .rodata should be executable too, but that doesn't
27 * matter yet because we (currently) assume that the NX bit is not
28 * supported anyway. */
29
30 .data : AT(ADDR(.data) - 0xbf000000) ALIGN(4K) {
31 __DATA_BASE__ = .;
32 *(.data)
33 __DATA_END__ = .;
34 }
35 .bss : AT(ADDR(.bss) - 0xbf000000) ALIGN(4K) {
36 __BSS_BASE__ = .;
37 *(.bss)
38 /* Reserving 16KiB for the stack. A __STACK_TOP__ is not really
39 * needed (yet). */
40 . += 16K;
41 __STACK_BOTTOM__ = .;
42 __BSS_END__ = .;
43 }
44 }