blob: 4c242319fbd9b58b62ef3eb1aed1bdbfdbd3c91b [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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc.
18 */
19
20#include <memlayout.h>
21
22/* This file is included inside a SECTIONS block */
23
24/* First we place the code and read only data (typically const declared).
25 * This could theoretically be placed in rom.
Julius Werner52a92602015-09-11 16:17:50 -070026 * The '.' in '.text . : {' is actually significant to prevent missing some
27 * SoC's entry points due to artificial alignment restrictions, see
28 * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
Aaron Durbin4de29d42015-09-03 22:49:36 -050029 */
Julius Werner52a92602015-09-11 16:17:50 -070030.text . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050031 _program = .;
32 _text = .;
Aaron Durbin14714e12015-09-04 12:06:05 -050033 /*
34 * The .rom.* sections are to acommodate x86 romstage. romcc as well
35 * as the assembly files put their text and data in these sections.
36 */
37 *(.rom.text);
38 *(.rom.data);
Aaron Durbin4de29d42015-09-03 22:49:36 -050039 *(.text._start);
40 *(.text.stage_entry);
Julius Werner52a92602015-09-11 16:17:50 -070041 KEEP(*(.id));
Aaron Durbin4de29d42015-09-03 22:49:36 -050042 *(.text);
43 *(.text.*);
44
Aaron Durbin83bc0db2015-09-06 10:45:18 -050045#if ENV_RAMSTAGE || ENV_ROMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050046 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
47 _cbmem_init_hooks = .;
48 KEEP(*(.rodata.cbmem_init_hooks));
49 _ecbmem_init_hooks = .;
50#endif
51
Aaron Durbin83bc0db2015-09-06 10:45:18 -050052#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050053 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
54 _pci_drivers = .;
55 KEEP(*(.rodata.pci_driver));
56 _epci_drivers = .;
57 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
58 _cpu_drivers = .;
59 KEEP(*(.rodata.cpu_driver));
60 _ecpu_drivers = .;
61#endif
62
63 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
64 *(.rodata);
65 *(.rodata.*);
66 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
67 _etext = .;
68} : to_load
69
70#if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070071.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020072 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050073 __CTOR_LIST__ = .;
74 KEEP(*(.ctors));
75 LONG(0);
76 LONG(0);
77 __CTOR_END__ = .;
78}
79#endif
80
81/* Include data, bss, and heap in that order. Not defined for all stages. */
82#if ARCH_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070083.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050084 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
85 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050086
87#if ENV_RMODULE
88 _rmodule_params = .;
89 KEEP(*(.module_parameters));
90 _ermodule_params = .;
91#endif
92
Aaron Durbin4de29d42015-09-03 22:49:36 -050093 *(.data);
94 *(.data.*);
95
96#ifdef __PRE_RAM__
97 PROVIDE(_preram_cbmem_console = .);
98 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -050099#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -0500100 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
101 _bs_init_begin = .;
102 KEEP(*(.bs_init));
103 LONG(0);
104 LONG(0);
105 _ebs_init_begin = .;
106#endif
107
108 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
109 _edata = .;
110}
111#endif
112
113#if ARCH_STAGE_HAS_BSS_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700114.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500115 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
116 _bss = .;
117 *(.bss)
118 *(.bss.*)
119 *(.sbss)
120 *(.sbss.*)
121 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
122 _ebss = .;
123}
124#endif
125
126#if ARCH_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700127.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500128 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
129 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500130 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500131 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
132 _eheap = .;
133}
134#endif
135
136_eprogram = .;
137
138/* Discard the sections we don't need/want */
139
140/DISCARD/ : {
141 *(.comment)
142 *(.comment.*)
143 *(.note)
144 *(.note.*)
145 *(.eh_frame);
146}