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. |
| 26 | */ |
| 27 | .text : { |
| 28 | _program = .; |
| 29 | _text = .; |
| 30 | *(.text._start); |
| 31 | *(.text.stage_entry); |
| 32 | *(.text); |
| 33 | *(.text.*); |
| 34 | |
| 35 | #if ENV_RAMSTAGE || ENV_ROMSTAGE |
| 36 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 37 | _cbmem_init_hooks = .; |
| 38 | KEEP(*(.rodata.cbmem_init_hooks)); |
| 39 | _ecbmem_init_hooks = .; |
| 40 | #endif |
| 41 | |
| 42 | #if ENV_RAMSTAGE |
| 43 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 44 | _pci_drivers = .; |
| 45 | KEEP(*(.rodata.pci_driver)); |
| 46 | _epci_drivers = .; |
| 47 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 48 | _cpu_drivers = .; |
| 49 | KEEP(*(.rodata.cpu_driver)); |
| 50 | _ecpu_drivers = .; |
| 51 | #endif |
| 52 | |
| 53 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 54 | *(.rodata); |
| 55 | *(.rodata.*); |
| 56 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 57 | _etext = .; |
| 58 | } : to_load |
| 59 | |
| 60 | #if ENV_RAMSTAGE && IS_ENABLED(CONFIG_COVERAGE) |
| 61 | .ctors : { |
| 62 | . = ALIGN(0x100) |
| 63 | __CTOR_LIST__ = .; |
| 64 | KEEP(*(.ctors)); |
| 65 | LONG(0); |
| 66 | LONG(0); |
| 67 | __CTOR_END__ = .; |
| 68 | } |
| 69 | #endif |
| 70 | |
| 71 | /* Include data, bss, and heap in that order. Not defined for all stages. */ |
| 72 | #if ARCH_STAGE_HAS_DATA_SECTION |
| 73 | .data : { |
| 74 | . = ALIGN(ARCH_CACHELINE_ALIGN_SIZE); |
| 75 | _data = .; |
| 76 | *(.data); |
| 77 | *(.data.*); |
| 78 | |
| 79 | #ifdef __PRE_RAM__ |
| 80 | PROVIDE(_preram_cbmem_console = .); |
| 81 | PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); |
| 82 | #elif ENV_RAMSTAGE |
| 83 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 84 | _bs_init_begin = .; |
| 85 | KEEP(*(.bs_init)); |
| 86 | LONG(0); |
| 87 | LONG(0); |
| 88 | _ebs_init_begin = .; |
| 89 | #endif |
| 90 | |
| 91 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 92 | _edata = .; |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | #if ARCH_STAGE_HAS_BSS_SECTION |
| 97 | .bss : { |
| 98 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 99 | _bss = .; |
| 100 | *(.bss) |
| 101 | *(.bss.*) |
| 102 | *(.sbss) |
| 103 | *(.sbss.*) |
| 104 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 105 | _ebss = .; |
| 106 | } |
| 107 | #endif |
| 108 | |
| 109 | #if ARCH_STAGE_HAS_HEAP_SECTION |
| 110 | .heap : { |
| 111 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 112 | _heap = .; |
| 113 | . += CONFIG_HEAP_SIZE; |
| 114 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 115 | _eheap = .; |
| 116 | } |
| 117 | #endif |
| 118 | |
| 119 | _eprogram = .; |
| 120 | |
| 121 | /* Discard the sections we don't need/want */ |
| 122 | |
| 123 | /DISCARD/ : { |
| 124 | *(.comment) |
| 125 | *(.comment.*) |
| 126 | *(.note) |
| 127 | *(.note.*) |
| 128 | *(.eh_frame); |
| 129 | } |