blob: 6f096dc360da8b148b53be6a0efc6660d649ae18 [file] [log] [blame]
Angel Pons118a9c72020-04-02 23:48:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin4de29d42015-09-03 22:49:36 -05003
4#include <memlayout.h>
5
6/* This file is included inside a SECTIONS block */
7
8/* First we place the code and read only data (typically const declared).
9 * This could theoretically be placed in rom.
Julius Werner52a92602015-09-11 16:17:50 -070010 * The '.' in '.text . : {' is actually significant to prevent missing some
11 * SoC's entry points due to artificial alignment restrictions, see
12 * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
Aaron Durbin4de29d42015-09-03 22:49:36 -050013 */
Julius Werner52a92602015-09-11 16:17:50 -070014.text . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050015 _program = .;
16 _text = .;
Aaron Durbin14714e12015-09-04 12:06:05 -050017 /*
18 * The .rom.* sections are to acommodate x86 romstage. romcc as well
19 * as the assembly files put their text and data in these sections.
20 */
21 *(.rom.text);
22 *(.rom.data);
Aaron Durbin4de29d42015-09-03 22:49:36 -050023 *(.text._start);
24 *(.text.stage_entry);
Julius Werner99f46832018-05-16 14:14:04 -070025#if (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && \
Julius Wernercd49cce2019-03-05 16:53:33 -080026 !CONFIG(COMPRESS_BOOTBLOCK)) && \
27 !(CONFIG(ARCH_BOOTBLOCK_X86_32) || \
28 CONFIG(ARCH_BOOTBLOCK_X86_64))
Julius Werner52a92602015-09-11 16:17:50 -070029 KEEP(*(.id));
Nico Huberf1778ce2017-07-28 19:30:43 +020030#endif
Aaron Durbin4de29d42015-09-03 22:49:36 -050031 *(.text);
32 *(.text.*);
33
Aaron Durbin1e9a9142016-09-16 16:23:21 -050034#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
Aaron Durbin4de29d42015-09-03 22:49:36 -050035 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
36 _cbmem_init_hooks = .;
37 KEEP(*(.rodata.cbmem_init_hooks));
38 _ecbmem_init_hooks = .;
Stefan Reinauerf6b10392016-05-20 15:17:17 -070039#endif
Lee Leahyefcee9f2016-04-29 17:26:36 -070040
41 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
42 _rsbe_init_begin = .;
43 KEEP(*(.rsbe_init));
44 _ersbe_init_begin = .;
Aaron Durbin4de29d42015-09-03 22:49:36 -050045
Aaron Durbin83bc0db2015-09-06 10:45:18 -050046#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050047 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
48 _pci_drivers = .;
49 KEEP(*(.rodata.pci_driver));
50 _epci_drivers = .;
51 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
52 _cpu_drivers = .;
53 KEEP(*(.rodata.cpu_driver));
54 _ecpu_drivers = .;
55#endif
56
57 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
58 *(.rodata);
59 *(.rodata.*);
60 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
61 _etext = .;
62} : to_load
63
Julius Wernercd49cce2019-03-05 16:53:33 -080064#if ENV_RAMSTAGE && CONFIG(COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070065.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020066 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050067 __CTOR_LIST__ = .;
68 KEEP(*(.ctors));
69 LONG(0);
70 LONG(0);
71 __CTOR_END__ = .;
72}
73#endif
74
75/* Include data, bss, and heap in that order. Not defined for all stages. */
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +030076#if ENV_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070077.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050078 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
79 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050080
Aaron Durbin7f8afe02016-03-18 12:21:23 -050081/*
82 * The postcar phase uses a stack value that is located in the relocatable
83 * module section. While the postcar stage could be linked like smm and
84 * other rmodules the postcar stage needs similar semantics of the more
85 * traditional stages in the coreboot infrastructure. Therefore it's easier
86 * to specialize this case.
87 */
88#if ENV_RMODULE || ENV_POSTCAR
Aaron Durbindde76292015-09-05 12:59:26 -050089 _rmodule_params = .;
90 KEEP(*(.module_parameters));
91 _ermodule_params = .;
92#endif
93
Aaron Durbin4de29d42015-09-03 22:49:36 -050094 *(.data);
95 *(.data.*);
Aaron Durbin9a2790e2016-10-28 12:24:48 -050096 *(.sdata);
97 *(.sdata.*);
Aaron Durbin4de29d42015-09-03 22:49:36 -050098
Kyösti Mälkkie3acc8f2019-09-13 10:49:20 +030099#if ENV_ROMSTAGE_OR_BEFORE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500100 PROVIDE(_preram_cbmem_console = .);
101 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500102#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500103 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
104 _bs_init_begin = .;
105 KEEP(*(.bs_init));
106 LONG(0);
107 LONG(0);
108 _ebs_init_begin = .;
109#endif
110
111 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
112 _edata = .;
113}
114#endif
115
Kyösti Mälkkia165c072019-08-22 09:44:44 +0300116#if ENV_STAGE_HAS_BSS_SECTION && !ENV_CACHE_AS_RAM
Julius Werner52a92602015-09-11 16:17:50 -0700117.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500118 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
119 _bss = .;
120 *(.bss)
121 *(.bss.*)
122 *(.sbss)
123 *(.sbss.*)
124 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
125 _ebss = .;
126}
127#endif
128
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +0300129#if ENV_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700130.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500131 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
132 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500133 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500134 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
135 _eheap = .;
136}
137#endif
138
139_eprogram = .;
140
141/* Discard the sections we don't need/want */
142
Patrick Georgifab8ae72016-04-13 20:55:34 +0200143zeroptr = 0;
Patrick Georgiff8076d2016-01-27 08:18:16 +0100144
Aaron Durbin4de29d42015-09-03 22:49:36 -0500145/DISCARD/ : {
146 *(.comment)
147 *(.comment.*)
148 *(.note)
149 *(.note.*)
150 *(.eh_frame);
151}