blob: b56a400cebcee74fc061c1007411796b6924d5f3 [file] [log] [blame]
Angel Pons118a9c72020-04-02 23:48:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin4de29d42015-09-03 22:49:36 -05002
3#include <memlayout.h>
4
5/* This file is included inside a SECTIONS block */
6
7/* First we place the code and read only data (typically const declared).
8 * This could theoretically be placed in rom.
Julius Werner52a92602015-09-11 16:17:50 -07009 * The '.' in '.text . : {' is actually significant to prevent missing some
10 * SoC's entry points due to artificial alignment restrictions, see
11 * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
Aaron Durbin4de29d42015-09-03 22:49:36 -050012 */
Julius Werner52a92602015-09-11 16:17:50 -070013.text . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050014 _program = .;
15 _text = .;
Aaron Durbin14714e12015-09-04 12:06:05 -050016 /*
17 * The .rom.* sections are to acommodate x86 romstage. romcc as well
18 * as the assembly files put their text and data in these sections.
19 */
20 *(.rom.text);
21 *(.rom.data);
Aaron Durbin4de29d42015-09-03 22:49:36 -050022 *(.text._start);
23 *(.text.stage_entry);
Julius Werner99f46832018-05-16 14:14:04 -070024#if (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && \
Julius Wernercd49cce2019-03-05 16:53:33 -080025 !CONFIG(COMPRESS_BOOTBLOCK)) && \
26 !(CONFIG(ARCH_BOOTBLOCK_X86_32) || \
27 CONFIG(ARCH_BOOTBLOCK_X86_64))
Julius Werner52a92602015-09-11 16:17:50 -070028 KEEP(*(.id));
Nico Huberf1778ce2017-07-28 19:30:43 +020029#endif
Aaron Durbin4de29d42015-09-03 22:49:36 -050030 *(.text);
31 *(.text.*);
32
Aaron Durbin1e9a9142016-09-16 16:23:21 -050033#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
Aaron Durbin4de29d42015-09-03 22:49:36 -050034 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
35 _cbmem_init_hooks = .;
36 KEEP(*(.rodata.cbmem_init_hooks));
37 _ecbmem_init_hooks = .;
Stefan Reinauerf6b10392016-05-20 15:17:17 -070038#endif
Lee Leahyefcee9f2016-04-29 17:26:36 -070039
40 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
41 _rsbe_init_begin = .;
42 KEEP(*(.rsbe_init));
43 _ersbe_init_begin = .;
Aaron Durbin4de29d42015-09-03 22:49:36 -050044
Aaron Durbin83bc0db2015-09-06 10:45:18 -050045#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050046 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
47 _pci_drivers = .;
48 KEEP(*(.rodata.pci_driver));
49 _epci_drivers = .;
50 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
51 _cpu_drivers = .;
52 KEEP(*(.rodata.cpu_driver));
53 _ecpu_drivers = .;
54#endif
55
56 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
57 *(.rodata);
58 *(.rodata.*);
59 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
60 _etext = .;
61} : to_load
62
Julius Wernercd49cce2019-03-05 16:53:33 -080063#if ENV_RAMSTAGE && CONFIG(COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070064.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020065 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050066 __CTOR_LIST__ = .;
67 KEEP(*(.ctors));
68 LONG(0);
69 LONG(0);
70 __CTOR_END__ = .;
71}
72#endif
73
74/* Include data, bss, and heap in that order. Not defined for all stages. */
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +030075#if ENV_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070076.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050077 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
78 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050079
Aaron Durbin7f8afe02016-03-18 12:21:23 -050080/*
81 * The postcar phase uses a stack value that is located in the relocatable
82 * module section. While the postcar stage could be linked like smm and
83 * other rmodules the postcar stage needs similar semantics of the more
84 * traditional stages in the coreboot infrastructure. Therefore it's easier
85 * to specialize this case.
86 */
87#if ENV_RMODULE || ENV_POSTCAR
Aaron Durbindde76292015-09-05 12:59:26 -050088 _rmodule_params = .;
89 KEEP(*(.module_parameters));
90 _ermodule_params = .;
91#endif
92
Aaron Durbin4de29d42015-09-03 22:49:36 -050093 *(.data);
94 *(.data.*);
Aaron Durbin9a2790e2016-10-28 12:24:48 -050095 *(.sdata);
96 *(.sdata.*);
Aaron Durbin4de29d42015-09-03 22:49:36 -050097
Kyösti Mälkkie3acc8f2019-09-13 10:49:20 +030098#if ENV_ROMSTAGE_OR_BEFORE
Aaron Durbin4de29d42015-09-03 22:49:36 -050099 PROVIDE(_preram_cbmem_console = .);
100 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500101#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500102 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
103 _bs_init_begin = .;
104 KEEP(*(.bs_init));
105 LONG(0);
106 LONG(0);
107 _ebs_init_begin = .;
108#endif
109
110 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
111 _edata = .;
112}
113#endif
114
Kyösti Mälkkia165c072019-08-22 09:44:44 +0300115#if ENV_STAGE_HAS_BSS_SECTION && !ENV_CACHE_AS_RAM
Julius Werner52a92602015-09-11 16:17:50 -0700116.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500117 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
118 _bss = .;
119 *(.bss)
120 *(.bss.*)
121 *(.sbss)
122 *(.sbss.*)
123 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
124 _ebss = .;
125}
126#endif
127
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +0300128#if ENV_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700129.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500130 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
131 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500132 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500133 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
134 _eheap = .;
135}
136#endif
137
138_eprogram = .;
139
140/* Discard the sections we don't need/want */
141
Patrick Georgifab8ae72016-04-13 20:55:34 +0200142zeroptr = 0;
Patrick Georgiff8076d2016-01-27 08:18:16 +0100143
Aaron Durbin4de29d42015-09-03 22:49:36 -0500144/DISCARD/ : {
145 *(.comment)
146 *(.comment.*)
147 *(.note)
148 *(.note.*)
149 *(.eh_frame);
150}