blob: 4668aea2c6b9f6986b9253fb7c564888e8970aec [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 Werner52a92602015-09-11 16:17:50 -070037 KEEP(*(.id));
Aaron Durbin4de29d42015-09-03 22:49:36 -050038 *(.text);
39 *(.text.*);
40
Aaron Durbin1e9a9142016-09-16 16:23:21 -050041#if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
Aaron Durbin4de29d42015-09-03 22:49:36 -050042 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
43 _cbmem_init_hooks = .;
44 KEEP(*(.rodata.cbmem_init_hooks));
45 _ecbmem_init_hooks = .;
Stefan Reinauerf6b10392016-05-20 15:17:17 -070046#endif
Lee Leahyefcee9f2016-04-29 17:26:36 -070047
48 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
49 _rsbe_init_begin = .;
50 KEEP(*(.rsbe_init));
51 _ersbe_init_begin = .;
Aaron Durbin4de29d42015-09-03 22:49:36 -050052
Aaron Durbin83bc0db2015-09-06 10:45:18 -050053#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050054 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
55 _pci_drivers = .;
56 KEEP(*(.rodata.pci_driver));
57 _epci_drivers = .;
58 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
59 _cpu_drivers = .;
60 KEEP(*(.rodata.cpu_driver));
61 _ecpu_drivers = .;
62#endif
63
64 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
65 *(.rodata);
66 *(.rodata.*);
67 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
68 _etext = .;
69} : to_load
70
71#if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070072.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020073 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050074 __CTOR_LIST__ = .;
75 KEEP(*(.ctors));
76 LONG(0);
77 LONG(0);
78 __CTOR_END__ = .;
79}
80#endif
81
82/* Include data, bss, and heap in that order. Not defined for all stages. */
83#if ARCH_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070084.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050085 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
86 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050087
Aaron Durbin7f8afe02016-03-18 12:21:23 -050088/*
89 * The postcar phase uses a stack value that is located in the relocatable
90 * module section. While the postcar stage could be linked like smm and
91 * other rmodules the postcar stage needs similar semantics of the more
92 * traditional stages in the coreboot infrastructure. Therefore it's easier
93 * to specialize this case.
94 */
95#if ENV_RMODULE || ENV_POSTCAR
Aaron Durbindde76292015-09-05 12:59:26 -050096 _rmodule_params = .;
97 KEEP(*(.module_parameters));
98 _ermodule_params = .;
99#endif
100
Aaron Durbin4de29d42015-09-03 22:49:36 -0500101 *(.data);
102 *(.data.*);
103
104#ifdef __PRE_RAM__
105 PROVIDE(_preram_cbmem_console = .);
106 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500107#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500108 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
109 _bs_init_begin = .;
110 KEEP(*(.bs_init));
111 LONG(0);
112 LONG(0);
113 _ebs_init_begin = .;
114#endif
115
116 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
117 _edata = .;
118}
119#endif
120
121#if ARCH_STAGE_HAS_BSS_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700122.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500123 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
124 _bss = .;
125 *(.bss)
126 *(.bss.*)
127 *(.sbss)
128 *(.sbss.*)
129 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
130 _ebss = .;
131}
132#endif
133
134#if ARCH_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700135.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500136 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
137 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500138 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500139 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
140 _eheap = .;
141}
142#endif
143
144_eprogram = .;
145
146/* Discard the sections we don't need/want */
147
Patrick Georgifab8ae72016-04-13 20:55:34 +0200148zeroptr = 0;
Patrick Georgiff8076d2016-01-27 08:18:16 +0100149
Aaron Durbin4de29d42015-09-03 22:49:36 -0500150/DISCARD/ : {
151 *(.comment)
152 *(.comment.*)
153 *(.note)
154 *(.note.*)
155 *(.eh_frame);
156}