Rename __attribute__((packed)) --> __packed
[coreboot.git] / src / lib / program.ld
blob1526aadf0a3e83d9210bacf6d51dd1ab51a62e84
1 /*
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  */
16 #include <memlayout.h>
18 /* This file is included inside a SECTIONS block */
20 /* First we place the code and read only data (typically const declared).
21  * This could theoretically be placed in rom.
22  * 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
25  */
26 .text . : {
27         _program = .;
28         _text = .;
29         /*
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);
35         *(.text._start);
36         *(.text.stage_entry);
37         KEEP(*(.id));
38         *(.text);
39         *(.text.*);
41 #if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR
42         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
43         _cbmem_init_hooks = .;
44         KEEP(*(.rodata.cbmem_init_hooks));
45         _ecbmem_init_hooks = .;
46 #endif
48         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
49         _rsbe_init_begin = .;
50         KEEP(*(.rsbe_init));
51         _ersbe_init_begin = .;
53 #if ENV_RAMSTAGE
54         . = 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
64         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
65         *(.rodata);
66         *(.rodata.*);
67         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
68         _etext = .;
69 } : to_load
71 #if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE)
72 .ctors . : {
73         . = ALIGN(0x100);
74         __CTOR_LIST__ = .;
75         KEEP(*(.ctors));
76         LONG(0);
77         LONG(0);
78         __CTOR_END__ = .;
80 #endif
82 /* Include data, bss, and heap in that order. Not defined for all stages. */
83 #if ARCH_STAGE_HAS_DATA_SECTION
84 .data . : {
85         . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE);
86         _data = .;
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
96         _rmodule_params = .;
97         KEEP(*(.module_parameters));
98         _ermodule_params = .;
99 #endif
101         *(.data);
102         *(.data.*);
103         *(.sdata);
104         *(.sdata.*);
106 #ifdef __PRE_RAM__
107         PROVIDE(_preram_cbmem_console = .);
108         PROVIDE(_epreram_cbmem_console = _preram_cbmem_console);
109 #elif ENV_RAMSTAGE
110         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
111         _bs_init_begin = .;
112         KEEP(*(.bs_init));
113         LONG(0);
114         LONG(0);
115         _ebs_init_begin = .;
116 #endif
118         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
119         _edata = .;
121 #endif
123 #if ARCH_STAGE_HAS_BSS_SECTION
124 .bss . : {
125         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
126         _bss = .;
127         *(.bss)
128         *(.bss.*)
129         *(.sbss)
130         *(.sbss.*)
131         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
132         _ebss = .;
134 #endif
136 #if ARCH_STAGE_HAS_HEAP_SECTION
137 .heap . : {
138         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
139         _heap = .;
140         . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE);
141         . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
142         _eheap = .;
144 #endif
146 _eprogram = .;
148 /* Discard the sections we don't need/want */
150 zeroptr = 0;
152 /DISCARD/ : {
153         *(.comment)
154         *(.comment.*)
155         *(.note)
156         *(.note.*)
157         *(.eh_frame);