blob: 3b6aa2ecba04ab27c3c4a21eb24a97498e7993ae [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 Durbin4de29d42015-09-03 22:49:36 -050016 *(.text._start);
17 *(.text.stage_entry);
Kyösti Mälkki9d1cbf12020-06-08 06:05:03 +030018#if !ENV_X86 && (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && !CONFIG(COMPRESS_BOOTBLOCK))
Julius Werner52a92602015-09-11 16:17:50 -070019 KEEP(*(.id));
Nico Huberf1778ce2017-07-28 19:30:43 +020020#endif
Aaron Durbin4de29d42015-09-03 22:49:36 -050021 *(.text);
22 *(.text.*);
23
Aaron Durbin1e9a9142016-09-16 16:23:21 -050024#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
Aaron Durbin4de29d42015-09-03 22:49:36 -050025 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
26 _cbmem_init_hooks = .;
27 KEEP(*(.rodata.cbmem_init_hooks));
28 _ecbmem_init_hooks = .;
Stefan Reinauerf6b10392016-05-20 15:17:17 -070029#endif
Lee Leahyefcee9f2016-04-29 17:26:36 -070030
31 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
32 _rsbe_init_begin = .;
33 KEEP(*(.rsbe_init));
34 _ersbe_init_begin = .;
Aaron Durbin4de29d42015-09-03 22:49:36 -050035
Aaron Durbin83bc0db2015-09-06 10:45:18 -050036#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050037 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
38 _pci_drivers = .;
39 KEEP(*(.rodata.pci_driver));
40 _epci_drivers = .;
41 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
42 _cpu_drivers = .;
43 KEEP(*(.rodata.cpu_driver));
44 _ecpu_drivers = .;
45#endif
46
47 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
48 *(.rodata);
49 *(.rodata.*);
50 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
51 _etext = .;
52} : to_load
53
Harshit Sharma9c88fb82020-06-17 20:19:00 -070054#if ENV_RAMSTAGE && (CONFIG(COVERAGE) || CONFIG(ASAN_IN_RAMSTAGE))
Julius Werner52a92602015-09-11 16:17:50 -070055.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020056 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050057 __CTOR_LIST__ = .;
58 KEEP(*(.ctors));
59 LONG(0);
60 LONG(0);
61 __CTOR_END__ = .;
62}
63#endif
64
65/* Include data, bss, and heap in that order. Not defined for all stages. */
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +030066#if ENV_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070067.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050068 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
69 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050070
Aaron Durbin7f8afe02016-03-18 12:21:23 -050071/*
72 * The postcar phase uses a stack value that is located in the relocatable
73 * module section. While the postcar stage could be linked like smm and
74 * other rmodules the postcar stage needs similar semantics of the more
75 * traditional stages in the coreboot infrastructure. Therefore it's easier
76 * to specialize this case.
77 */
78#if ENV_RMODULE || ENV_POSTCAR
Aaron Durbindde76292015-09-05 12:59:26 -050079 _rmodule_params = .;
80 KEEP(*(.module_parameters));
81 _ermodule_params = .;
82#endif
83
Aaron Durbin4de29d42015-09-03 22:49:36 -050084 *(.data);
85 *(.data.*);
Aaron Durbin9a2790e2016-10-28 12:24:48 -050086 *(.sdata);
87 *(.sdata.*);
Aaron Durbin4de29d42015-09-03 22:49:36 -050088
Kyösti Mälkkie3acc8f2019-09-13 10:49:20 +030089#if ENV_ROMSTAGE_OR_BEFORE
Aaron Durbin4de29d42015-09-03 22:49:36 -050090 PROVIDE(_preram_cbmem_console = .);
91 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -050092#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050093 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
94 _bs_init_begin = .;
95 KEEP(*(.bs_init));
96 LONG(0);
97 LONG(0);
98 _ebs_init_begin = .;
99#endif
100
101 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
102 _edata = .;
103}
104#endif
105
Kyösti Mälkkifcbbb912020-04-20 10:21:39 +0300106#if !ENV_CACHE_AS_RAM
Julius Werner52a92602015-09-11 16:17:50 -0700107.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500108 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
109 _bss = .;
110 *(.bss)
111 *(.bss.*)
112 *(.sbss)
113 *(.sbss.*)
114 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
115 _ebss = .;
116}
117#endif
118
Kyösti Mälkkif2cc52b2019-08-21 07:15:38 +0300119#if ENV_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700120.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500121 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
122 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500123 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500124 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
125 _eheap = .;
126}
127#endif
128
Harshit Sharma9c88fb82020-06-17 20:19:00 -0700129#if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE)
130 _shadow_size = (_eheap - _data) >> 3;
131 REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE)
132#endif
133
Aaron Durbin4de29d42015-09-03 22:49:36 -0500134_eprogram = .;
135
136/* Discard the sections we don't need/want */
137
Patrick Georgifab8ae72016-04-13 20:55:34 +0200138zeroptr = 0;
Patrick Georgiff8076d2016-01-27 08:18:16 +0100139
Aaron Durbin4de29d42015-09-03 22:49:36 -0500140/DISCARD/ : {
141 *(.comment)
142 *(.comment.*)
143 *(.note)
144 *(.note.*)
145 *(.eh_frame);
146}