-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.x
More file actions
144 lines (111 loc) · 3.95 KB
/
link.x
File metadata and controls
144 lines (111 loc) · 3.95 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
source: https://github.com/rust-embedded/riscv/blob/fdc3bb65a258/riscv-rt/link.x.in
*/
ENTRY(_start);
MEMORY {
/*
LENGTH = num_ram_procs * 4096*4
0x10000000 = 128*128 * 4096*4
0x8000000 = 128*64 * 4096*4
0x3000000 = 128*24 * 4096*4
0x1000000 = 128*8 * 4096*4
*/
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x200000
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x200000
MMIO (rw) : ORIGIN = 0xf0000000, LENGTH = 16
}
REGION_ALIAS("REGION_TEXT", ROM);
REGION_ALIAS("REGION_RODATA", ROM);
REGION_ALIAS("REGION_DATA", RAM);
REGION_ALIAS("REGION_BSS", RAM);
REGION_ALIAS("REGION_HEAP", RAM);
REGION_ALIAS("REGION_STACK", RAM);
PROVIDE(_stack_start = ORIGIN(REGION_STACK) + LENGTH(REGION_STACK));
PROVIDE(_stack_size = 4K);
/* users can optionally enable the heap by adding another linker script to override this value */
PROVIDE(_heap_size = 0);
SECTIONS {
.text : {
__stext = .;
KEEP(*(.text.start));
*(.text.reset);
*(.text .text.*);
. = ALIGN(4);
__etext = .;
} > REGION_TEXT
.rodata : ALIGN(4) {
. = ALIGN(4);
__srodata = .;
*(.srodata .srodata.*);
*(.rodata .rodata.*);
. = ALIGN(4);
__erodata = .;
} > REGION_RODATA
.data : ALIGN(4) {
. = ALIGN(4);
__sdata = .;
PROVIDE(__global_pointer$ = . + 0x800);
*(.sdata .sdata.* .sdata2 .sdata2.*);
*(.data .data.*);
} > REGION_DATA AT > REGION_RODATA
. = ALIGN(4);
__edata = .;
__sidata = LOADADDR(.data);
.bss (NOLOAD) : ALIGN(4) {
. = ALIGN(4);
__sbss = .;
*(.sbss .sbss.* .bss .bss.*);
} > REGION_BSS
. = ALIGN(4);
__ebss = .;
/* fictitious region that represents the memory available for the heap */
.heap (NOLOAD) : {
__sheap = .;
. += _heap_size;
. = ALIGN(4);
__eheap = .;
} > REGION_HEAP
/* fictitious region that represents the memory available for the stack */
.stack (NOLOAD) : {
__estack = .;
. = ABSOLUTE(_stack_start);
__sstack = .;
} > REGION_STACK
/* fake output .got section */
/* Dynamic relocations are unsupported. This section is only used to detect
relocatable code in the input files and raise an error if relocatable code
is found */
.got (INFO) :
{
KEEP(*(.got .got.*));
}
}
/* Do not exceed this mark in the error messages above | */
ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
ERROR(mlogv32): the start of the REGION_TEXT must be 4-byte aligned");
ASSERT(ORIGIN(REGION_RODATA) % 4 == 0, "
ERROR(mlogv32): the start of the REGION_RODATA must be 4-byte aligned");
ASSERT(ORIGIN(REGION_DATA) % 4 == 0, "
ERROR(mlogv32): the start of the REGION_DATA must be 4-byte aligned");
ASSERT(ORIGIN(REGION_HEAP) % 4 == 0, "
ERROR(mlogv32): the start of the REGION_HEAP must be 4-byte aligned");
ASSERT(ORIGIN(REGION_STACK) % 4 == 0, "
ERROR(mlogv32): the start of the REGION_STACK must be 4-byte aligned");
ASSERT(__sdata % 4 == 0 && __edata % 4 == 0, "
BUG(mlogv32): .data is not 4-byte aligned");
ASSERT(__sidata % 4 == 0, "
BUG(mlogv32): the LMA of .data is not 4-byte aligned");
ASSERT(__sbss % 4 == 0 && __ebss % 4 == 0, "
BUG(mlogv32): .bss is not 4-byte aligned");
ASSERT(__sheap % 4 == 0, "
BUG(mlogv32): start of .heap is not 4-byte aligned");
ASSERT(SIZEOF(.stack) > _stack_size, "
ERROR(mlogv32): .stack section is too small for allocating the stack.
Consider changing `_stack_size`.");
/* # Other checks */
ASSERT(SIZEOF(.got) == 0, "
ERROR(mlogv32): .got section detected in the input files. Dynamic relocations are not
supported. If you are linking to C code compiled using the `cc` crate then modify your
build script to compile the C code _without_ the -fPIC flag. See the documentation of
the `cc::Build.pic` method for details.");
/* Do not exceed this mark in the error messages above | */