blob: 865b5f6aa73156b055076c5729ba4e4df9d01b00 [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 Durbin83bc0db2015-09-06 10:45:18 -050041#if ENV_RAMSTAGE || ENV_ROMSTAGE
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 = .;
46#endif
47
Aaron Durbin83bc0db2015-09-06 10:45:18 -050048#if ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050049 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
50 _pci_drivers = .;
51 KEEP(*(.rodata.pci_driver));
52 _epci_drivers = .;
53 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
54 _cpu_drivers = .;
55 KEEP(*(.rodata.cpu_driver));
56 _ecpu_drivers = .;
57#endif
58
59 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
60 *(.rodata);
61 *(.rodata.*);
62 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
63 _etext = .;
64} : to_load
65
66#if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
Julius Werner52a92602015-09-11 16:17:50 -070067.ctors . : {
Patrick Georgi9cc8e922015-09-27 13:45:17 +020068 . = ALIGN(0x100);
Aaron Durbin4de29d42015-09-03 22:49:36 -050069 __CTOR_LIST__ = .;
70 KEEP(*(.ctors));
71 LONG(0);
72 LONG(0);
73 __CTOR_END__ = .;
74}
75#endif
76
77/* Include data, bss, and heap in that order. Not defined for all stages. */
78#if ARCH_STAGE_HAS_DATA_SECTION
Julius Werner52a92602015-09-11 16:17:50 -070079.data . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -050080 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
81 _data = .;
Aaron Durbindde76292015-09-05 12:59:26 -050082
83#if ENV_RMODULE
84 _rmodule_params = .;
85 KEEP(*(.module_parameters));
86 _ermodule_params = .;
87#endif
88
Aaron Durbin4de29d42015-09-03 22:49:36 -050089 *(.data);
90 *(.data.*);
91
92#ifdef __PRE_RAM__
93 PROVIDE(_preram_cbmem_console = .);
94 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
Aaron Durbin83bc0db2015-09-06 10:45:18 -050095#elif ENV_RAMSTAGE
Aaron Durbin4de29d42015-09-03 22:49:36 -050096 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
97 _bs_init_begin = .;
98 KEEP(*(.bs_init));
99 LONG(0);
100 LONG(0);
101 _ebs_init_begin = .;
102#endif
103
104 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
105 _edata = .;
106}
107#endif
108
109#if ARCH_STAGE_HAS_BSS_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700110.bss . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500111 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
112 _bss = .;
113 *(.bss)
114 *(.bss.*)
115 *(.sbss)
116 *(.sbss.*)
117 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
118 _ebss = .;
119}
120#endif
121
122#if ARCH_STAGE_HAS_HEAP_SECTION
Julius Werner52a92602015-09-11 16:17:50 -0700123.heap . : {
Aaron Durbin4de29d42015-09-03 22:49:36 -0500124 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
125 _heap = .;
Aaron Durbindde76292015-09-05 12:59:26 -0500126 . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
Aaron Durbin4de29d42015-09-03 22:49:36 -0500127 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
128 _eheap = .;
129}
130#endif
131
132_eprogram = .;
133
134/* Discard the sections we don't need/want */
135
136/DISCARD/ : {
137 *(.comment)
138 *(.comment.*)
139 *(.note)
140 *(.note.*)
141 *(.eh_frame);
142}