Angel Pons | 118a9c7 | 2020-04-02 23:48:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 3 | |
| 4 | #include <memlayout.h> |
| 5 | |
| 6 | /* This file is included inside a SECTIONS block */ |
| 7 | |
| 8 | /* First we place the code and read only data (typically const declared). |
| 9 | * This could theoretically be placed in rom. |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 10 | * The '.' in '.text . : {' is actually significant to prevent missing some |
| 11 | * SoC's entry points due to artificial alignment restrictions, see |
| 12 | * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 13 | */ |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 14 | .text . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 15 | _program = .; |
| 16 | _text = .; |
Aaron Durbin | 14714e1 | 2015-09-04 12:06:05 -0500 | [diff] [blame] | 17 | /* |
| 18 | * The .rom.* sections are to acommodate x86 romstage. romcc as well |
| 19 | * as the assembly files put their text and data in these sections. |
| 20 | */ |
| 21 | *(.rom.text); |
| 22 | *(.rom.data); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 23 | *(.text._start); |
| 24 | *(.text.stage_entry); |
Julius Werner | 99f4683 | 2018-05-16 14:14:04 -0700 | [diff] [blame] | 25 | #if (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && \ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 26 | !CONFIG(COMPRESS_BOOTBLOCK)) && \ |
| 27 | !(CONFIG(ARCH_BOOTBLOCK_X86_32) || \ |
| 28 | CONFIG(ARCH_BOOTBLOCK_X86_64)) |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 29 | KEEP(*(.id)); |
Nico Huber | f1778ce | 2017-07-28 19:30:43 +0200 | [diff] [blame] | 30 | #endif |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 31 | *(.text); |
| 32 | *(.text.*); |
| 33 | |
Aaron Durbin | 1e9a914 | 2016-09-16 16:23:21 -0500 | [diff] [blame] | 34 | #if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 35 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 36 | _cbmem_init_hooks = .; |
| 37 | KEEP(*(.rodata.cbmem_init_hooks)); |
| 38 | _ecbmem_init_hooks = .; |
Stefan Reinauer | f6b1039 | 2016-05-20 15:17:17 -0700 | [diff] [blame] | 39 | #endif |
Lee Leahy | efcee9f | 2016-04-29 17:26:36 -0700 | [diff] [blame] | 40 | |
| 41 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 42 | _rsbe_init_begin = .; |
| 43 | KEEP(*(.rsbe_init)); |
| 44 | _ersbe_init_begin = .; |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 45 | |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 46 | #if ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 47 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 48 | _pci_drivers = .; |
| 49 | KEEP(*(.rodata.pci_driver)); |
| 50 | _epci_drivers = .; |
| 51 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 52 | _cpu_drivers = .; |
| 53 | KEEP(*(.rodata.cpu_driver)); |
| 54 | _ecpu_drivers = .; |
| 55 | #endif |
| 56 | |
| 57 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 58 | *(.rodata); |
| 59 | *(.rodata.*); |
| 60 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 61 | _etext = .; |
| 62 | } : to_load |
| 63 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 64 | #if ENV_RAMSTAGE && CONFIG(COVERAGE) |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 65 | .ctors . : { |
Patrick Georgi | 9cc8e92 | 2015-09-27 13:45:17 +0200 | [diff] [blame] | 66 | . = ALIGN(0x100); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 67 | __CTOR_LIST__ = .; |
| 68 | KEEP(*(.ctors)); |
| 69 | LONG(0); |
| 70 | LONG(0); |
| 71 | __CTOR_END__ = .; |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | /* Include data, bss, and heap in that order. Not defined for all stages. */ |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 76 | #if ENV_STAGE_HAS_DATA_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 77 | .data . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 78 | . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE); |
| 79 | _data = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 80 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 81 | /* |
| 82 | * The postcar phase uses a stack value that is located in the relocatable |
| 83 | * module section. While the postcar stage could be linked like smm and |
| 84 | * other rmodules the postcar stage needs similar semantics of the more |
| 85 | * traditional stages in the coreboot infrastructure. Therefore it's easier |
| 86 | * to specialize this case. |
| 87 | */ |
| 88 | #if ENV_RMODULE || ENV_POSTCAR |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 89 | _rmodule_params = .; |
| 90 | KEEP(*(.module_parameters)); |
| 91 | _ermodule_params = .; |
| 92 | #endif |
| 93 | |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 94 | *(.data); |
| 95 | *(.data.*); |
Aaron Durbin | 9a2790e | 2016-10-28 12:24:48 -0500 | [diff] [blame] | 96 | *(.sdata); |
| 97 | *(.sdata.*); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 98 | |
Kyösti Mälkki | e3acc8f | 2019-09-13 10:49:20 +0300 | [diff] [blame] | 99 | #if ENV_ROMSTAGE_OR_BEFORE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 100 | PROVIDE(_preram_cbmem_console = .); |
| 101 | PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 102 | #elif ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 103 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 104 | _bs_init_begin = .; |
| 105 | KEEP(*(.bs_init)); |
| 106 | LONG(0); |
| 107 | LONG(0); |
| 108 | _ebs_init_begin = .; |
| 109 | #endif |
| 110 | |
| 111 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 112 | _edata = .; |
| 113 | } |
| 114 | #endif |
| 115 | |
Kyösti Mälkki | a165c07 | 2019-08-22 09:44:44 +0300 | [diff] [blame] | 116 | #if ENV_STAGE_HAS_BSS_SECTION && !ENV_CACHE_AS_RAM |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 117 | .bss . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 118 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 119 | _bss = .; |
| 120 | *(.bss) |
| 121 | *(.bss.*) |
| 122 | *(.sbss) |
| 123 | *(.sbss.*) |
| 124 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 125 | _ebss = .; |
| 126 | } |
| 127 | #endif |
| 128 | |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 129 | #if ENV_STAGE_HAS_HEAP_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 130 | .heap . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 131 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 132 | _heap = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 133 | . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 134 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 135 | _eheap = .; |
| 136 | } |
| 137 | #endif |
| 138 | |
| 139 | _eprogram = .; |
| 140 | |
| 141 | /* Discard the sections we don't need/want */ |
| 142 | |
Patrick Georgi | fab8ae7 | 2016-04-13 20:55:34 +0200 | [diff] [blame] | 143 | zeroptr = 0; |
Patrick Georgi | ff8076d | 2016-01-27 08:18:16 +0100 | [diff] [blame] | 144 | |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 145 | /DISCARD/ : { |
| 146 | *(.comment) |
| 147 | *(.comment.*) |
| 148 | *(.note) |
| 149 | *(.note.*) |
| 150 | *(.eh_frame); |
| 151 | } |