-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinker.ld
87 lines (72 loc) · 3.8 KB
/
linker.ld
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
SECTIONS
{
. = 0x80000; /* Start address of the kernel image */
.text : {
KEEP(*(.text.boot)) /* Keep the boot section in the final output file */
kernel/src/*(.text .text.* .gnu.linkonce.t*)
kernel/src/interrupts/*(.text .text.* .gnu.linkonce.t*)
kernel/src/interrupts/handlers/*(.text .text.* .gnu.linkonce.t*)
kernel/src/peripherals/*(.text .text.* .gnu.linkonce.t*)
kernel/src/scheduler/*(.text .text.* .gnu.linkonce.t*)
kernel/src/sys_calls/*(.text .text.* .gnu.linkonce.t*)
kernel/src/util/*(.text .text.* .gnu.linkonce.t*)
}
.rodata : {
kernel/src/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/interrupts/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/interrupts/handlers/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/peripherals/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/scheduler/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/sys_calls/*(.rodata .rodata.* .gnu.linkonce.r*)
kernel/src/util/*(.rodata .rodata.* .gnu.linkonce.r*)
}
/* PROVIDE -> for variables which are referenced but not initialized in the section */
PROVIDE(_data = .); /* Initialize data start address to current location pointer */
.data : {
kernel/src/*(.data .data.* .gnu.linkonce.d*)
kernel/src/interrupts/*(.data .data.* .gnu.linkonce.d*)
kernel/src/interrupts/handlers/*(.data .data.* .gnu.linkonce.d*)
kernel/src/peripherals/*(.data .data.* .gnu.linkonce.d*)
kernel/src/scheduler/*(.data .data.* .gnu.linkonce.d*)
kernel/src/sys_calls/*(.data .data.* .gnu.linkonce.d*)
kernel/src/util/*(.data .data.* .gnu.linkonce.d*)
} /* Section for initialized data */
. = ALIGN(0x1000);
.bss (NOLOAD) : { /* Section for uninitialized data; NOLOAD -> Don't allocate space in linking, will be allocated and initialized in runtime */
. = ALIGN(16); /* Align the current location pointer to the next 16bit boundary */
__bss_start = .; /* Start address of the BSS section */
kernel/src/*(.bss .bss.*)
kernel/src/interrupts/*(.bss .bss.*)
kernel/src/interrupts/handlers/*(.bss .bss.*)
kernel/src/peripherals/*(.bss .bss.*)
kernel/src/scheduler/*(.bss .bss.*)
kernel/src/sys_calls/*(.bss .bss.*)
kernel/src/util/*(.bss .bss.*)
__bss_end = .; /* End address of the BSS section */
}
/* Page directory for the identity mapped memory (first 16 MiB); lower half virtual address space*/
/* NOTE: The page directory is 4 KiB in size, with each entry being 8 bytes long */
/* The table addresses must be aligned to 4 KiB boundaries */
. = ALIGN(0x1000);
id_pg_dir = .;
.data.id_pg_dir : { . += (3 * (1 << 12)); }
/* Page directory for the high memory (16 MiB to 4 GiB) and the SoC and RP1 peripheral address space; higher half virtual address space */
. = ALIGN(0x1000);
high_pg_dir = .;
.data.high_pg_dir : { . += (8 * (1 << 12)); }
/* Userspace code sections */
. = ALIGN(0x1000);
__user_begin = .;
.text.user : { test/src*(.text .text.*) }
.rodata.user : { test/src*(.rodata .rodata.*) }
.data.user : { test/src*(.data .data.*) }
.bss.user : { test/src*(.bss .bss.*) }
. = ALIGN(0x1000);
__user_end = .;
_end = .; /* End address of loaded program data */
/* DISCARD certain sections from the final output file, like comments, metadata and debugging information */
/DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
}
/* .gnu.linkonce.d -> used by the GNU linker for certain optimizations
* for example, merge identical constants across various files into a single section to save space and access times */
__bss_size = (__bss_end - __bss_start)>>3; /* Size of the BSS section */