aboutsummaryrefslogtreecommitdiff
path: root/linker.ld
blob: 5ff3b62617792616cf52401488d604b7f9ce3faa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ENTRY(_start)
OUTPUT_FORMAT(elf32-i386)

VADDR_BASE = 0xc0000000;

SECTIONS
{
    /*
     * First put the multiboot header, as it is required to be put very early
     * early in the image or the bootloader won't recognize the file format.
     */
    . = 0;
    _kernel_start = .;
    .multiboot : {
        *(.multiboot.header)
        *(.multiboot.text)
    }

    /* Begin putting sections at 1 MiB */
    . = VADDR_BASE + 1M;

    .text ALIGN(4K) : AT(ADDR(.text) - VADDR_BASE) {
        *(.text*)
    }
 
    /* Read-only data. */
    .rodata ALIGN(4K) : AT(ADDR(.rodata) - VADDR_BASE) {
        *(.rodata*)
    }
 
    /* Read-write data (initialized) */
    .data ALIGN(4K) : AT(ADDR(.data) - VADDR_BASE) {
        begin_ctors = .;
        KEEP(*(.init_array));   /* global constructors */
        end_ctors = .;

        begin_constinit = .;
        *(.constinit)
        end_constinit = .;

        *(.data)
    }
 
    /* Read-write data (uninitialized) and stack */
    .bss ALIGN(4K) : AT(ADDR(.bss) - VADDR_BASE) {
        *(.pages)
        *(.bss)
        *(.stack)
    }
    _kernel_end = .;
}