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