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