summaryrefslogtreecommitdiff
path: root/kernel/link.ld
blob: b61cd01716abd0da699de122bb552a28300ccea4 (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
52
53
54
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(_start)

KERNEL_BASE = 0xffffffff80000000;

PHDRS
{
        text PT_LOAD;
        rodata PT_LOAD;
        data PT_LOAD;
}

SECTIONS
{
        . = KERNEL_BASE;
        .text : {
                *(.text .text.*)
        } : text
        
        . = ALIGN(CONSTANT(MAXPAGESIZE));

        .rodata : {
                *(.rodata .rodata.*)
        } :rodata

        /* Add a .note.gnu.build-id output section in case a build ID flag is added to the */
        /* linker command. */
        .note.gnu.build-id : {
                *(.note.gnu.build-id)
        } :rodata

        /* Move to the next memory page for .data */
        . = ALIGN(CONSTANT(MAXPAGESIZE));

        .data : {
                *(.data .data.*)
        } :data

        /* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
        /* unnecessary zeros will be written to the binary. */
        /* If you need, for example, .init_array and .fini_array, those should be placed */
        /* above this. */
        .bss : {
                    *(.bss .bss.*)
                    *(COMMON)
        } :data

        /* Discard .note.* and .eh_frame* since they may cause issues on some hosts. */
        /DISCARD/ : {
                    *(.eh_frame*)
                    *(.note .note.*)
        }
}