Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 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 | * |
| 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. |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 26 | * The '.' in '.text . : {' is actually significant to prevent missing some |
| 27 | * SoC's entry points due to artificial alignment restrictions, see |
| 28 | * https://sourceware.org/binutils/docs/ld/Output-Section-Address.html |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 29 | */ |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 30 | .text . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 31 | _program = .; |
| 32 | _text = .; |
Aaron Durbin | 14714e1 | 2015-09-04 12:06:05 -0500 | [diff] [blame] | 33 | /* |
| 34 | * The .rom.* sections are to acommodate x86 romstage. romcc as well |
| 35 | * as the assembly files put their text and data in these sections. |
| 36 | */ |
| 37 | *(.rom.text); |
| 38 | *(.rom.data); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 39 | *(.text._start); |
| 40 | *(.text.stage_entry); |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 41 | KEEP(*(.id)); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 42 | *(.text); |
| 43 | *(.text.*); |
| 44 | |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 45 | #if ENV_RAMSTAGE || ENV_ROMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 46 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 47 | _cbmem_init_hooks = .; |
| 48 | KEEP(*(.rodata.cbmem_init_hooks)); |
| 49 | _ecbmem_init_hooks = .; |
| 50 | #endif |
| 51 | |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 52 | #if ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 53 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 54 | _pci_drivers = .; |
| 55 | KEEP(*(.rodata.pci_driver)); |
| 56 | _epci_drivers = .; |
| 57 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 58 | _cpu_drivers = .; |
| 59 | KEEP(*(.rodata.cpu_driver)); |
| 60 | _ecpu_drivers = .; |
| 61 | #endif |
| 62 | |
| 63 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 64 | *(.rodata); |
| 65 | *(.rodata.*); |
| 66 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 67 | _etext = .; |
| 68 | } : to_load |
| 69 | |
| 70 | #if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE) |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 71 | .ctors . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 72 | . = ALIGN(0x100) |
| 73 | __CTOR_LIST__ = .; |
| 74 | KEEP(*(.ctors)); |
| 75 | LONG(0); |
| 76 | LONG(0); |
| 77 | __CTOR_END__ = .; |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | /* Include data, bss, and heap in that order. Not defined for all stages. */ |
| 82 | #if ARCH_STAGE_HAS_DATA_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 83 | .data . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 84 | . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE); |
| 85 | _data = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 86 | |
| 87 | #if ENV_RMODULE |
| 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.*); |
| 95 | |
| 96 | #ifdef __PRE_RAM__ |
| 97 | PROVIDE(_preram_cbmem_console = .); |
| 98 | PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 99 | #elif ENV_RAMSTAGE |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 100 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 101 | _bs_init_begin = .; |
| 102 | KEEP(*(.bs_init)); |
| 103 | LONG(0); |
| 104 | LONG(0); |
| 105 | _ebs_init_begin = .; |
| 106 | #endif |
| 107 | |
| 108 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 109 | _edata = .; |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | #if ARCH_STAGE_HAS_BSS_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 114 | .bss . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 115 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 116 | _bss = .; |
| 117 | *(.bss) |
| 118 | *(.bss.*) |
| 119 | *(.sbss) |
| 120 | *(.sbss.*) |
| 121 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 122 | _ebss = .; |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | #if ARCH_STAGE_HAS_HEAP_SECTION |
Julius Werner | 52a9260 | 2015-09-11 16:17:50 -0700 | [diff] [blame] | 127 | .heap . : { |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 128 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 129 | _heap = .; |
Aaron Durbin | dde7629 | 2015-09-05 12:59:26 -0500 | [diff] [blame] | 130 | . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE); |
Aaron Durbin | 4de29d4 | 2015-09-03 22:49:36 -0500 | [diff] [blame] | 131 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 132 | _eheap = .; |
| 133 | } |
| 134 | #endif |
| 135 | |
| 136 | _eprogram = .; |
| 137 | |
| 138 | /* Discard the sections we don't need/want */ |
| 139 | |
| 140 | /DISCARD/ : { |
| 141 | *(.comment) |
| 142 | *(.comment.*) |
| 143 | *(.note) |
| 144 | *(.note.*) |
| 145 | *(.eh_frame); |
| 146 | } |