|
| 1 | +/* |
| 2 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD) |
| 3 | + * Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com> |
| 4 | + * |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + */ |
| 7 | + |
| 8 | + |
| 9 | +#include <zephyr/linker/sections.h> |
| 10 | +#include <zephyr/linker/linker-defs.h> |
| 11 | +#include <zephyr/linker/linker-tool.h> |
| 12 | +#include <layout.h> |
| 13 | + |
| 14 | +/* These sections are specific to this CPU */ |
| 15 | +#define _EXCEPTION_SECTION_NAME exceptions |
| 16 | +#define _RESET_SECTION_NAME reset |
| 17 | + |
| 18 | +#define ROMABLE_REGION app_ram |
| 19 | +#define RAMABLE_REGION app_ram |
| 20 | + |
| 21 | +ENTRY(CONFIG_KERNEL_ENTRY) |
| 22 | + |
| 23 | +#if CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0 |
| 24 | + _HEAP_SIZE = CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE; |
| 25 | +#else |
| 26 | + _HEAP_SIZE = 32K; |
| 27 | +#endif |
| 28 | + |
| 29 | +SECTIONS |
| 30 | +{ |
| 31 | + |
| 32 | +#include <zephyr/linker/rel-sections.ld> |
| 33 | + SECTION_PROLOGUE(.text,,) |
| 34 | + { |
| 35 | + /* microblaze vectors from 0x0 to 0x50 */ |
| 36 | + __mb_vectors = .; |
| 37 | + KEEP (*(.vectors.reset)) |
| 38 | + . = __mb_vectors + 0x8; |
| 39 | + KEEP (*(.vectors.sw_exception)) |
| 40 | + . = __mb_vectors + 0x10; |
| 41 | + KEEP (*(.vectors.interrupt)) |
| 42 | + . = __mb_vectors + 0x20; |
| 43 | + KEEP (*(.vectors.hw_exception)) |
| 44 | + |
| 45 | + /* code */ |
| 46 | + . = __mb_vectors + 0x50; |
| 47 | + |
| 48 | + __text_region_start = .; |
| 49 | + |
| 50 | + *(.text) |
| 51 | + *(.text.*) |
| 52 | + *(.gnu.linkonce.t.*) |
| 53 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 54 | + |
| 55 | + __text_region_end = .; |
| 56 | + __text_region_size = __text_region_end - __text_region_start; |
| 57 | + |
| 58 | + SECTION_PROLOGUE(_EXCEPTION_SECTION_NAME,,) |
| 59 | + { |
| 60 | + KEEP(*(".exception.entry.*")) |
| 61 | + *(".exception.other.*") |
| 62 | + |
| 63 | + } GROUP_LINK_IN(ROMABLE_REGION) |
| 64 | + |
| 65 | + SECTION_PROLOGUE(.note.gnu.build-id,,) |
| 66 | + { |
| 67 | + KEEP (*(.note.gnu.build-id)) |
| 68 | + } GROUP_LINK_IN(ROMABLE_REGION) |
| 69 | + |
| 70 | + SECTION_PROLOGUE(.init,,) |
| 71 | + { |
| 72 | + KEEP (*(.init)) |
| 73 | + } GROUP_LINK_IN(ROMABLE_REGION) |
| 74 | + |
| 75 | + SECTION_PROLOGUE(.fini,,) |
| 76 | + { |
| 77 | + KEEP (*(.fini)) |
| 78 | + } GROUP_LINK_IN(ROMABLE_REGION) |
| 79 | + |
| 80 | + __rodata_region_start = .; |
| 81 | + |
| 82 | +#include <zephyr/linker/common-rom.ld> |
| 83 | +#include <zephyr/linker/thread-local-storage.ld> |
| 84 | +#include <zephyr/linker/cplusplus-rom.ld> |
| 85 | + |
| 86 | + SECTION_PROLOGUE(.rodata,,) |
| 87 | + { |
| 88 | + . = ALIGN(4); |
| 89 | + __rodata_start = .; |
| 90 | + *(.rodata) |
| 91 | + *(.rodata.*) |
| 92 | + *(.gnu.linkonce.r.*) |
| 93 | + |
| 94 | +#include <snippets-rodata.ld> |
| 95 | + |
| 96 | + } GROUP_LINK_IN(ROMABLE_REGION) |
| 97 | + |
| 98 | +#include <zephyr/linker/cplusplus-rom.ld> |
| 99 | + |
| 100 | +#ifdef CONFIG_CPLUSPLUS |
| 101 | + .dtors : { |
| 102 | + __DTOR_LIST__ = .; |
| 103 | + ___DTORS_LIST___ = .; |
| 104 | + KEEP (*crtbegin.o(.dtors)) |
| 105 | + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) |
| 106 | + KEEP (*(SORT(.dtors.*))) |
| 107 | + KEEP (*(.dtors)) |
| 108 | + PROVIDE(__DTOR_END__ = .); |
| 109 | + PROVIDE(___DTORS_END___ = .); |
| 110 | + } > app_ram |
| 111 | +#endif |
| 112 | + |
| 113 | + __rodata_end = .; |
| 114 | + __rodata_region_end = .; |
| 115 | + __rodata_region_size = __rodata_region_end - __rodata_region_start; |
| 116 | + |
| 117 | + SECTION_PROLOGUE(.sdata2,,) |
| 118 | + { |
| 119 | + . = ALIGN(4); |
| 120 | + __sdata2_start = .; |
| 121 | + *( .sdata2) |
| 122 | + *(.sdata2.*) |
| 123 | + *(.gnu.linkonce.s2.*) |
| 124 | + . = ALIGN(4); |
| 125 | + __sdata2_end = .; |
| 126 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 127 | + |
| 128 | +#include <zephyr/linker/common-ram.ld> |
| 129 | + |
| 130 | + SECTION_PROLOGUE(.data,,) |
| 131 | + { |
| 132 | + . = ALIGN(4); |
| 133 | + __data_start = .; |
| 134 | + *(.data) |
| 135 | + *(.data.*) |
| 136 | + |
| 137 | +#include <snippets-rwdata.ld> |
| 138 | + |
| 139 | + *(.gnu.linkonce.d.*) |
| 140 | + . = ALIGN(4); |
| 141 | + |
| 142 | +#include <snippets-ram-sections.ld> |
| 143 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 144 | + |
| 145 | +#include <snippets-data-sections.ld> |
| 146 | + |
| 147 | + __data_end = .; |
| 148 | + __data_size = __data_end - __data_start; |
| 149 | + |
| 150 | +#include <zephyr/linker/cplusplus-ram.ld> |
| 151 | + |
| 152 | + SECTION_PROLOGUE(.got,,) |
| 153 | + { |
| 154 | + . = ALIGN(4); |
| 155 | + *(.got) |
| 156 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 157 | + |
| 158 | + SECTION_PROLOGUE(.got1,,) |
| 159 | + { |
| 160 | + . = ALIGN(4); |
| 161 | + *(.got1) |
| 162 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 163 | + |
| 164 | + SECTION_PROLOGUE(.got2,,) |
| 165 | + { |
| 166 | + . = ALIGN(4); |
| 167 | + *(.got2) |
| 168 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 169 | + |
| 170 | + SECTION_PROLOGUE(.jcr,,) |
| 171 | + { |
| 172 | + . = ALIGN(4); |
| 173 | + *(.jcr) |
| 174 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 175 | + |
| 176 | + SECTION_PROLOGUE(.sdata,,) |
| 177 | + { |
| 178 | + . = ALIGN(4); |
| 179 | + __sdata_start = .; |
| 180 | + *(.sdata) |
| 181 | + *(.sdata.*) |
| 182 | + *(.gnu.linkonce.s.*) |
| 183 | + |
| 184 | + __sdata_end = .; |
| 185 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 186 | + |
| 187 | + SECTION_PROLOGUE(.sbss (NOLOAD),,) |
| 188 | + { |
| 189 | + . = ALIGN(4); |
| 190 | + __sbss_start = .; |
| 191 | + *(.sbss) |
| 192 | + *(.sbss.*) |
| 193 | + *(.gnu.linkonce.sb.*) |
| 194 | + . = ALIGN(4); |
| 195 | + __sbss_end = .; |
| 196 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 197 | + |
| 198 | + _gp = (__sbss_end + __sdata_start) / 2; |
| 199 | + PROVIDE(gp = _gp); |
| 200 | + |
| 201 | + SECTION_PROLOGUE(.tdata,,) |
| 202 | + { |
| 203 | + . = ALIGN(4); |
| 204 | + __tdata_start = .; |
| 205 | + *(.tdata) |
| 206 | + *(.tdata.*) |
| 207 | + *(.gnu.linkonce.td.*) |
| 208 | + __tdata_end = .; |
| 209 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 210 | + |
| 211 | + SECTION_PROLOGUE(.tbss,,) |
| 212 | + { |
| 213 | + . = ALIGN(4); |
| 214 | + __tbss_start = .; |
| 215 | + *(.tbss) |
| 216 | + *(.tbss.*) |
| 217 | + *(.gnu.linkonce.tb.*) |
| 218 | + __tbss_end = .; |
| 219 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 220 | + |
| 221 | + SECTION_PROLOGUE(.bss (NOLOAD),,) |
| 222 | + { |
| 223 | + . = ALIGN(4); |
| 224 | + __bss_start = .; |
| 225 | + *(.bss) |
| 226 | + *(.bss.*) |
| 227 | + *(.gnu.linkonce.b.*) |
| 228 | + *(COMMON) |
| 229 | + . = ALIGN(4); |
| 230 | + __bss_end = .; |
| 231 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 232 | + |
| 233 | + |
| 234 | + _SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); |
| 235 | + |
| 236 | + _SDA2_BASE_ = __sdata2_start + ((__sdata2_end - __sdata2_start) / 2 ); |
| 237 | + |
| 238 | +#include <zephyr/linker/common-noinit.ld> |
| 239 | + |
| 240 | +#ifdef CONFIG_GEN_ISR_TABLES |
| 241 | +#include <zephyr/linker/intlist.ld> |
| 242 | +#endif |
| 243 | + |
| 244 | +#include <snippets-sections.ld> |
| 245 | + |
| 246 | +#include <zephyr/linker/debug-sections.ld> |
| 247 | + |
| 248 | + SECTION_PROLOGUE(.heap (NOLOAD),,) |
| 249 | + { |
| 250 | + . += _HEAP_SIZE; |
| 251 | + . = ALIGN(4); |
| 252 | + } GROUP_LINK_IN(RAMABLE_REGION) |
| 253 | + |
| 254 | + _end = .; |
| 255 | + |
| 256 | +} |
0 commit comments