Updates to Freedom SoCs
[freedom-sifive.git] / bootrom / sdboot / linker / sdboot.elf.lds
1 OUTPUT_ARCH("riscv")
2 ENTRY(_prog_start)
3
4 INCLUDE memory.lds
5
6 PHDRS
7 {
8 text PT_LOAD;
9 data PT_LOAD;
10 bss PT_LOAD;
11 }
12
13 SECTIONS
14 {
15 PROVIDE(_ram = ORIGIN(memory_mem));
16 PROVIDE(_ram_end = _ram + LENGTH(memory_mem));
17
18 .text ALIGN((ORIGIN(maskrom_mem) + 0x0), 8) : AT(ALIGN((ORIGIN(maskrom_mem) + 0x0), 8)) {
19 PROVIDE(_ftext = .);
20 *(.text.init)
21 *(.text.unlikely .text.unlikely.*)
22 *(.text .text.* .gnu.linkonce.t.*)
23 PROVIDE(_etext = .);
24 . += 0x40; /* to create a gap between .text and .data b/c ifetch can fetch ahead from .data */
25 } >maskrom_mem :text
26
27 .eh_frame ALIGN((ADDR(.text) + SIZEOF(.text)), 8) : AT(ALIGN((LOADADDR(.text) + SIZEOF(.text)), 8)) {
28 *(.eh_frame)
29 } >maskrom_mem :text
30
31 .rodata ALIGN((ADDR(.eh_frame) + SIZEOF(.eh_frame)), 8) : AT(ALIGN((LOADADDR(.eh_frame) + SIZEOF(.eh_frame)), 8)) ALIGN_WITH_INPUT {
32 *(.rodata .rodata.* .gnu.linkonce.r.*)
33 } >maskrom_mem :data
34
35 .srodata ALIGN((ADDR(.rodata) + SIZEOF(.rodata)), 8) : AT(ALIGN((LOADADDR(.rodata) + SIZEOF(.rodata)), 8)) ALIGN_WITH_INPUT {
36 *(.srodata.cst16)
37 *(.srodata.cst8)
38 *(.srodata.cst4)
39 *(.srodata.cst2)
40 *(.srodata.*)
41 } >maskrom_mem :data
42
43 .data ALIGN((ADDR(.srodata) + SIZEOF(.srodata)), 8) : AT(ALIGN((LOADADDR(.srodata) + SIZEOF(.srodata)), 8)) ALIGN_WITH_INPUT {
44 *(.data .data.* .gnu.linkonce.d.*)
45 *(.tohost) /* TODO: Support sections that aren't explicitly listed in this linker script */
46 } >maskrom_mem :data
47
48 .sdata ALIGN((ADDR(.data) + SIZEOF(.data)), 8) : AT(ALIGN((LOADADDR(.data) + SIZEOF(.data)), 8)) ALIGN_WITH_INPUT {
49 *(.sdata .sdata.* .gnu.linkonce.s.*)
50 } >maskrom_mem :data
51
52 PROVIDE(_data = ADDR(.rodata));
53 PROVIDE(_data_lma = LOADADDR(.rodata));
54 PROVIDE(_edata = .);
55
56 .bss ALIGN((ORIGIN(memory_mem) + 0x0), 8) : AT(ALIGN((ORIGIN(memory_mem) + 0x0), 8)) ALIGN(8) {
57 PROVIDE(_fbss = .);
58 PROVIDE(__global_pointer$ = . + 0x7C0);
59 *(.sbss .sbss.* .gnu.linkonce.sb.*)
60 *(.bss .bss.* .gnu.linkonce.b.*)
61 . = ALIGN(8);
62 PROVIDE(_ebss = .);
63 } >memory_mem :bss
64
65 PROVIDE(_end = .);
66
67 /*
68 * heap_stack_region_usable_end: (ORIGIN(memory_mem) + LENGTH(memory_mem))
69 * heap_stack_min_size: 4096
70 * heap_stack_max_size: 1048576
71 */
72 PROVIDE(_sp = ALIGN(MIN((ORIGIN(memory_mem) + LENGTH(memory_mem)), _ebss + 1048576) - 7, 8));
73 PROVIDE(_heap_end = _sp - 2048);
74
75 /* This section is a noop and is only used for the ASSERT */
76 .stack : {
77 ASSERT(_sp >= (_ebss + 4096), "Error: No room left for the heap and stack");
78 }
79 }