blob: 156b86255c1c3e7f154871dbc3b70a141a875d07 [file] [log] [blame]
Aaron Durbin4de29d42015-09-03 22:49:36 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin4de29d42015-09-03 22:49:36 -050014 */
15
16#include <memlayout.h>
17
18/* This file is included inside a SECTIONS block */
19
20/* First we place the code and read only data (typically const declared).
21 * This could theoretically be placed in rom.
Julius Werner52a92602015-09-11 16:17:50 -070022 * The '.' in '.text . : {' is actually significant to prevent missing some
23 * SoC's entry points due to artificial alignment restrictions, see
24 * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
Aaron Durbin4de29d42015-09-03 22:49:36 -050025 */
Julius Werner52a92602015-09-11 16:17:50 -070026.text . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050027 _program = .;
28 _text = .;
Aaron Durbin14714e12015-09-04 12:06:05 -050029 /*
30 * The .rom.* sections are to acommodate x86 romstage. romcc as well
31 * as the assembly files put their text and data in these sections.
32 */
33 *(.rom.text);
34 *(.rom.data);
Aaron Durbin4de29d42015-09-03 22:49:36 -050035 *(.text._start);
36 *(.text.stage_entry);
Julius Werner99f46832018-05-16 14:14:04 -070037#if (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && \
38 !IS_ENABLED(CONFIG_COMPRESS_BOOTBLOCK)) && \
39 !(IS_ENABLED(CONFIG_ARCH_BOOTBLOCK_X86_32) || \
40 IS_ENABLED(CONFIG_ARCH_BOOTBLOCK_X86_64))
Julius Werner52a92602015-09-11 16:17:50 -070041 KEEP(*(.id));
Nico Huberf1778ce2017-07-28 19:30:43 +020042#endif
Aaron Durbin4de29d42015-09-03 22:49:36 -050043 *(.text);
44 *(.text.*);
45
Aaron Durbin1e9a9142016-09-16 16:23:21 -050046#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
Aaron Durbin4de29d42015-09-03 22:49:36 -050047 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
48 _cbmem_init_hooks = .;
49 KEEP(*(.rodata.cbmem_init_hooks));
50 _ecbmem_init_hooks = .;
Stefan Reinauerf6b10392016-05-20 15:17:17 -070051#endif
Lee Leahyefcee9f2016-04-29 17:26:36 -070052
53 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
54 _rsbe_init_begin = .;
55 KEEP(*(.rsbe_init));
56 _ersbe_init_begin = .;
Aaron Durbin4de29d42015-09-03 22:49:36 -050057
Aaron Durbin83bc0db2015-09-06 10:45:18 -050058#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050059 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
60 _pci_drivers = .;
61 KEEP(*(.rodata.pci_driver));
62 _epci_drivers = .;
63 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
64 _cpu_drivers = .;
65 KEEP(*(.rodata.cpu_driver));
66 _ecpu_drivers = .;
67#endif
68
69 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
70 *(.rodata);
71 *(.rodata.*);
72 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
73 _etext = .;
74} : to_load
75
76#if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070077.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020078 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050079 __CTOR_LIST__ = .;
80 KEEP(*(.ctors));
81 LONG(0);
82 LONG(0);
83 __CTOR_END__ = .;
84}
85#endif
86
87/* Include data, bss, and heap in that order. Not defined for all stages. */
88#if ARCH_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070089.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050090 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
91 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050092
Aaron Durbin7f8afe02016-03-18 12:21:23 -050093/*
94 * The postcar phase uses a stack value that is located in the relocatable
95 * module section. While the postcar stage could be linked like smm and
96 * other rmodules the postcar stage needs similar semantics of the more
97 * traditional stages in the coreboot infrastructure. Therefore it's easier
98 * to specialize this case.
99 */
100#if ENV_RMODULE || ENV_POSTCAR
Aaron Durbindde76292015-09-05 12:59:26 -0500101 _rmodule_params = .;
102 KEEP(*(.module_parameters));
103 _ermodule_params = .;
104#endif
105
Aaron Durbin4de29d42015-09-03 22:49:36 -0500106 *(.data);
107 *(.data.*);
Aaron Durbin9a2790e2016-10-28 12:24:48 -0500108 *(.sdata);
109 *(.sdata.*);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500110
111#ifdef __PRE_RAM__
112 PROVIDE(_preram_cbmem_console = .);
113 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500114#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500115 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
116 _bs_init_begin = .;
117 KEEP(*(.bs_init));
118 LONG(0);
119 LONG(0);
120 _ebs_init_begin = .;
121#endif
122
123 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
124 _edata = .;
125}
126#endif
127
128#if ARCH_STAGE_HAS_BSS_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700129.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500130 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
131 _bss = .;
132 *(.bss)
133 *(.bss.*)
134 *(.sbss)
135 *(.sbss.*)
136 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
137 _ebss = .;
138}
139#endif
140
141#if ARCH_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700142.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500143 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
144 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500145 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500146 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
147 _eheap = .;
148}
149#endif
150
151_eprogram = .;
152
153/* Discard the sections we don't need/want */
154
Patrick Georgifab8ae72016-04-13 20:55:34 +0200155zeroptr = 0;
Patrick Georgiff8076d2016-01-27 08:18:16 +0100156
Aaron Durbin4de29d42015-09-03 22:49:36 -0500157/DISCARD/ : {
158 *(.comment)
159 *(.comment.*)
160 *(.note)
161 *(.note.*)
162 *(.eh_frame);
163}