blob: cf011e9b081fb2a6f397b3ff6b61060d80fab721 [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.
26 */
27.text : {
28 _program = .;
29 _text = .;
Aaron Durbin14714e12015-09-04 12:06:05 -050030 /*
31 * The .rom.* sections are to acommodate x86 romstage. romcc as well
32 * as the assembly files put their text and data in these sections.
33 */
34 *(.rom.text);
35 *(.rom.data);
Aaron Durbin4de29d42015-09-03 22:49:36 -050036 *(.text._start);
37 *(.text.stage_entry);
38 *(.text);
39 *(.text.*);
40
41#if ENV_RAMSTAGE || ENV_ROMSTAGE
42 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
43 _cbmem_init_hooks = .;
44 KEEP(*(.rodata.cbmem_init_hooks));
45 _ecbmem_init_hooks = .;
46#endif
47
48#if ENV_RAMSTAGE
49 . = 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)
67.ctors : {
68 . = ALIGN(0x100)
69 __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
79.data : {
80 . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
81 _data = .;
82 *(.data);
83 *(.data.*);
84
85#ifdef __PRE_RAM__
86 PROVIDE(_preram_cbmem_console = .);
87 PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
88#elif ENV_RAMSTAGE
89 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
90 _bs_init_begin = .;
91 KEEP(*(.bs_init));
92 LONG(0);
93 LONG(0);
94 _ebs_init_begin = .;
95#endif
96
97 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
98 _edata = .;
99}
100#endif
101
102#if ARCH_STAGE_HAS_BSS_SECTION
103.bss : {
104 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
105 _bss = .;
106 *(.bss)
107 *(.bss.*)
108 *(.sbss)
109 *(.sbss.*)
110 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
111 _ebss = .;
112}
113#endif
114
115#if ARCH_STAGE_HAS_HEAP_SECTION
116.heap : {
117 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
118 _heap = .;
119 . += CONFIG_HEAP_SIZE;
120 . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
121 _eheap = .;
122}
123#endif
124
125_eprogram = .;
126
127/* Discard the sections we don't need/want */
128
129/DISCARD/ : {
130 *(.comment)
131 *(.comment.*)
132 *(.note)
133 *(.note.*)
134 *(.eh_frame);
135}