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 | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 16 | *(.text._start); |
| 17 | *(.text.stage_entry); |
Kyösti Mälkki | 9d1cbf1 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 18 | #if !ENV_X86 && (ENV_DECOMPRESSOR || ENV_BOOTBLOCK && !CONFIG(COMPRESS_BOOTBLOCK)) |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 19 | KEEP(*(.id)); |
Nico Huber | f1778ce | 2017-07-28 19:30:43 +0200 | [diff] [blame] | 20 | #endif |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 21 | *(.text); |
| 22 | *(.text.*); |
| 23 | |
Aaron Durbin | 1e9a914 | 2016-09-16 16:23:21 -0500 | [diff] [blame] | 24 | #if ENV_RAMSTAGE || ENV_ROMSTAGE || ENV_POSTCAR |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 25 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 26 | _cbmem_init_hooks = .; |
| 27 | KEEP(*(.rodata.cbmem_init_hooks)); |
| 28 | _ecbmem_init_hooks = .; |
Stefan Reinauer | f6b1039 | 2016-05-20 15:17:17 -0700 | [diff] [blame] | 29 | #endif |
Lee Leahy | efcee9f | 2016-04-29 17:26:36 -0700 | [diff] [blame] | 30 | |
| 31 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 32 | _rsbe_init_begin = .; |
| 33 | KEEP(*(.rsbe_init)); |
| 34 | _ersbe_init_begin = .; |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 35 | |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 36 | #if ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 37 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 38 | _pci_drivers = .; |
| 39 | KEEP(*(.rodata.pci_driver)); |
| 40 | _epci_drivers = .; |
| 41 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 42 | _cpu_drivers = .; |
| 43 | KEEP(*(.rodata.cpu_driver)); |
| 44 | _ecpu_drivers = .; |
| 45 | #endif |
| 46 | |
| 47 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 48 | *(.rodata); |
| 49 | *(.rodata.*); |
| 50 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 51 | _etext = .; |
| 52 | } : to_load |
| 53 | |
Harshit Sharma | 9c88fb8 | 2020-06-17 20:19:00 -0700 | [diff] [blame] | 54 | #if ENV_RAMSTAGE && (CONFIG(COVERAGE) || CONFIG(ASAN_IN_RAMSTAGE)) |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 55 | .ctors . : { |
Patrick Georgi | 9cc8e92 | 2015-09-27 13:45:17 +0200 | [diff] [blame] | 56 | . = ALIGN(0x100); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 57 | __CTOR_LIST__ = .; |
| 58 | KEEP(*(.ctors)); |
| 59 | LONG(0); |
| 60 | LONG(0); |
| 61 | __CTOR_END__ = .; |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | /* 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] | 66 | #if ENV_STAGE_HAS_DATA_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 67 | .data . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 68 | . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE); |
| 69 | _data = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 70 | |
Aaron Durbin | 7f8afe0 | 2016-03-18 12:21:23 -0500 | [diff] [blame] | 71 | /* |
| 72 | * The postcar phase uses a stack value that is located in the relocatable |
| 73 | * module section. While the postcar stage could be linked like smm and |
| 74 | * other rmodules the postcar stage needs similar semantics of the more |
| 75 | * traditional stages in the coreboot infrastructure. Therefore it's easier |
| 76 | * to specialize this case. |
| 77 | */ |
| 78 | #if ENV_RMODULE || ENV_POSTCAR |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 79 | _rmodule_params = .; |
| 80 | KEEP(*(.module_parameters)); |
| 81 | _ermodule_params = .; |
| 82 | #endif |
| 83 | |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 84 | *(.data); |
| 85 | *(.data.*); |
Aaron Durbin | 9a2790e | 2016-10-28 12:24:48 -0500 | [diff] [blame] | 86 | *(.sdata); |
| 87 | *(.sdata.*); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 88 | |
Kyösti Mälkki | e3acc8f | 2019-09-13 10:49:20 +0300 | [diff] [blame] | 89 | #if ENV_ROMSTAGE_OR_BEFORE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 90 | PROVIDE(_preram_cbmem_console = .); |
| 91 | PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 92 | #elif ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 93 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 94 | _bs_init_begin = .; |
| 95 | KEEP(*(.bs_init)); |
| 96 | LONG(0); |
| 97 | LONG(0); |
| 98 | _ebs_init_begin = .; |
| 99 | #endif |
| 100 | |
| 101 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 102 | _edata = .; |
| 103 | } |
| 104 | #endif |
| 105 | |
Kyösti Mälkki | fcbbb91 | 2020-04-20 10:21:39 +0300 | [diff] [blame] | 106 | #if !ENV_CACHE_AS_RAM |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 107 | .bss . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 108 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 109 | _bss = .; |
| 110 | *(.bss) |
| 111 | *(.bss.*) |
| 112 | *(.sbss) |
| 113 | *(.sbss.*) |
| 114 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 115 | _ebss = .; |
| 116 | } |
| 117 | #endif |
| 118 | |
Kyösti Mälkki | f2cc52b | 2019-08-21 07:15:38 +0300 | [diff] [blame] | 119 | #if ENV_STAGE_HAS_HEAP_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 120 | .heap . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 121 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 122 | _heap = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 123 | . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 124 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 125 | _eheap = .; |
| 126 | } |
| 127 | #endif |
| 128 | |
Harshit Sharma | 9c88fb8 | 2020-06-17 20:19:00 -0700 | [diff] [blame] | 129 | #if ENV_RAMSTAGE && CONFIG(ASAN_IN_RAMSTAGE) |
| 130 | _shadow_size = (_eheap - _data) >> 3; |
| 131 | REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE) |
| 132 | #endif |
| 133 | |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 134 | _eprogram = .; |
| 135 | |
| 136 | /* Discard the sections we don't need/want */ |
| 137 | |
Patrick Georgi | fab8ae7 | 2016-04-13 20:55:34 +0200 | [diff] [blame] | 138 | zeroptr = 0; |
Patrick Georgi | ff8076d | 2016-01-27 08:18:16 +0100 | [diff] [blame] | 139 | |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 140 | /DISCARD/ : { |
| 141 | *(.comment) |
| 142 | *(.comment.*) |
| 143 | *(.note) |
| 144 | *(.note.*) |
| 145 | *(.eh_frame); |
| 146 | } |