1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2c978b524SChris Zankel /* 3c978b524SChris Zankel * (C) Copyright 2007 Tensilica, Inc. 4c978b524SChris Zankel * (C) Copyright 2014 - 2016 Cadence Design Systems Inc. 5c978b524SChris Zankel */ 6c978b524SChris Zankel 7c978b524SChris Zankel #ifndef _XTENSA_LDSCRIPT_H 8c978b524SChris Zankel #define _XTENSA_LDSCRIPT_H 9c978b524SChris Zankel 10c978b524SChris Zankel /* 11c978b524SChris Zankel * This linker script is pre-processed with CPP to avoid hard-coding 12c978b524SChris Zankel * addresses that depend on the Xtensa core configuration, because 13c978b524SChris Zankel * this FPGA board can be used with a huge variety of Xtensa cores. 14c978b524SChris Zankel */ 15c978b524SChris Zankel 16c978b524SChris Zankel #include <asm/arch/core.h> 17c978b524SChris Zankel #include <asm/addrspace.h> 18c978b524SChris Zankel 19c978b524SChris Zankel #define ALIGN_LMA 4 20c978b524SChris Zankel #define LMA_EQ_VMA 21c978b524SChris Zankel #define FORCE_OUTPUT . = . 22c978b524SChris Zankel #define FOLLOWING(sec) \ 23c978b524SChris Zankel AT(((LOADADDR(sec) + SIZEOF(sec) + ALIGN_LMA-1)) & ~(ALIGN_LMA-1)) 24c978b524SChris Zankel 25c978b524SChris Zankel /* 26c978b524SChris Zankel * Specify an output section that will be added to the ROM store table 27c978b524SChris Zankel * (PACKED_SECTION) or one that will be resident in ROM (RESIDENT_SECTION). 28c978b524SChris Zankel * 'symname' is a base name for section boundary symbols *_start & *_end. 29c978b524SChris Zankel * 'lma' is the load address at which a section will be packed in ROM. 30c978b524SChris Zankel * 'region' is the basename identifying a memory region and program header. 31c978b524SChris Zankel * 'keep' prevents removal of empty sections (must be 'KEEP' or 'NOKEEP'). 32c978b524SChris Zankel */ 33c978b524SChris Zankel 34c978b524SChris Zankel #define RELOCATE1(_sec_) \ 35c978b524SChris Zankel LONG(_##_sec_##_start); \ 36c978b524SChris Zankel LONG(_##_sec_##_end); \ 37c978b524SChris Zankel LONG(LOADADDR(.##_sec_)); 38c978b524SChris Zankel 39c978b524SChris Zankel #define RELOCATE2(_sym_, _sec_) \ 40c978b524SChris Zankel LONG(_##_sym_##_##_sec_##_start); \ 41c978b524SChris Zankel LONG(_##_sym_##_##_sec_##_end); \ 42c978b524SChris Zankel LONG(LOADADDR(.##_sym_##.##_sec_)); 43c978b524SChris Zankel 44c978b524SChris Zankel #define SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_) \ 45c978b524SChris Zankel .##_sym_##.##_sec_ _vma_ : _lma_ \ 46c978b524SChris Zankel { \ 47c978b524SChris Zankel . = ALIGN(4); \ 48c978b524SChris Zankel _##_sym_##_##_sec_##_start = ABSOLUTE(.); \ 49c978b524SChris Zankel KEEP(*(.##_sym_##.##_sec_)) \ 50c978b524SChris Zankel _##_sym_##_##_sec_##_end = ABSOLUTE(.); \ 51c978b524SChris Zankel } 52c978b524SChris Zankel 53c978b524SChris Zankel /* In MMU configs there are two aliases of SYSROM, cached and uncached. 54c978b524SChris Zankel * For various reasons it is simpler to use the uncached mapping for load 55c978b524SChris Zankel * addresses, so ROM sections end up contiguous with the reset vector and 56c978b524SChris Zankel * we get a compact binary image. However we can gain performance by doing 57c978b524SChris Zankel * the unpacking from the cached ROM mapping. So we adjust all the load 58c978b524SChris Zankel * addresses in the ROM store table with an offset to the cached mapping, 59c978b524SChris Zankel * including the symbols referring to the ROM store table itself. 60c978b524SChris Zankel */ 61c978b524SChris Zankel 62c978b524SChris Zankel #define SECTION_ResetVector(_vma_, _lma_) \ 63c978b524SChris Zankel .ResetVector.text _vma_ : _lma_ \ 64c978b524SChris Zankel { \ 65c978b524SChris Zankel FORCE_OUTPUT; \ 66c978b524SChris Zankel KEEP(*(.ResetVector.text)); \ 67c978b524SChris Zankel KEEP(*(.reset.literal .reset.text)) \ 68c978b524SChris Zankel } 69c978b524SChris Zankel 70c978b524SChris Zankel #define SECTION_text(_vma_, _lma_) \ 71c978b524SChris Zankel .text _vma_ : _lma_ \ 72c978b524SChris Zankel { \ 73c978b524SChris Zankel _text_start = ABSOLUTE(.); \ 74c978b524SChris Zankel *(.literal .text) \ 75c978b524SChris Zankel *(.literal.* .text.* .stub) \ 76c978b524SChris Zankel *(.gnu.warning .gnu.linkonce.literal.*) \ 77c978b524SChris Zankel *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*) \ 78c978b524SChris Zankel *(.fini.literal) \ 79c978b524SChris Zankel *(.fini) \ 80c978b524SChris Zankel *(.gnu.version) \ 81c978b524SChris Zankel _text_end = ABSOLUTE(.); \ 82c978b524SChris Zankel } 83c978b524SChris Zankel 84c978b524SChris Zankel #define SECTION_rodata(_vma_, _lma_) \ 85c978b524SChris Zankel .rodata _vma_ : _lma_ \ 86c978b524SChris Zankel { \ 87c978b524SChris Zankel _rodata_start = ABSOLUTE(.); \ 88c978b524SChris Zankel *(.rodata) \ 89c978b524SChris Zankel *(.rodata.*) \ 90c978b524SChris Zankel *(.dtb.init.rodata) \ 91c978b524SChris Zankel *(.gnu.linkonce.r.*) \ 92c978b524SChris Zankel *(.rodata1) \ 93c978b524SChris Zankel __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); \ 94c978b524SChris Zankel *(.xt_except_table) \ 95c978b524SChris Zankel *(.gcc_except_table) \ 96c978b524SChris Zankel *(.gnu.linkonce.e.*) \ 97c978b524SChris Zankel *(.gnu.version_r) \ 98c978b524SChris Zankel . = ALIGN(16); \ 99c978b524SChris Zankel _rodata_end = ABSOLUTE(.); \ 100c978b524SChris Zankel } 101c978b524SChris Zankel 102c978b524SChris Zankel #define SECTION_u_boot_list(_vma_, _lma_) \ 103c978b524SChris Zankel .u_boot_list _vma_ : _lma_ \ 104c978b524SChris Zankel { \ 105c978b524SChris Zankel _u_boot_list_start = ABSOLUTE(.); \ 106c978b524SChris Zankel KEEP(*(SORT(.u_boot_list*))); \ 107c978b524SChris Zankel _u_boot_list_end = ABSOLUTE(.); \ 108c978b524SChris Zankel } 109c978b524SChris Zankel 110c978b524SChris Zankel #define SECTION_data(_vma_, _lma_) \ 111c978b524SChris Zankel .data _vma_ : _lma_ \ 112c978b524SChris Zankel { \ 113c978b524SChris Zankel _data_start = ABSOLUTE(.); \ 114c978b524SChris Zankel *(.data) \ 115c978b524SChris Zankel *(.data.*) \ 116c978b524SChris Zankel *(.gnu.linkonce.d.*) \ 117c978b524SChris Zankel *(.data1) \ 118c978b524SChris Zankel *(.sdata) \ 119c978b524SChris Zankel *(.sdata.*) \ 120c978b524SChris Zankel *(.gnu.linkonce.s.*) \ 121c978b524SChris Zankel *(.sdata2) \ 122c978b524SChris Zankel *(.sdata2.*) \ 123c978b524SChris Zankel *(.gnu.linkonce.s2.*) \ 124c978b524SChris Zankel *(.jcr) \ 125c978b524SChris Zankel *(.eh_frame) \ 126c978b524SChris Zankel *(.dynamic) \ 127c978b524SChris Zankel *(.gnu.version_d) \ 128c978b524SChris Zankel _data_end = ABSOLUTE(.); \ 129c978b524SChris Zankel } 130c978b524SChris Zankel 131c978b524SChris Zankel #define SECTION_lit4(_vma_, _lma_) \ 132c978b524SChris Zankel .lit4 _vma_ : _lma_ \ 133c978b524SChris Zankel { \ 134c978b524SChris Zankel _lit4_start = ABSOLUTE(.); \ 135c978b524SChris Zankel *(*.lit4) \ 136c978b524SChris Zankel *(.gnu.linkonce.lit4.*) \ 137c978b524SChris Zankel _lit4_end = ABSOLUTE(.); \ 138c978b524SChris Zankel } 139c978b524SChris Zankel 140c978b524SChris Zankel #define SECTION_bss(_vma_, _lma_) \ 141c978b524SChris Zankel .bss _vma_ : _lma_ \ 142c978b524SChris Zankel { \ 143c978b524SChris Zankel . = ALIGN(8); \ 144c978b524SChris Zankel _bss_start = ABSOLUTE(.); \ 145c978b524SChris Zankel __bss_start = ABSOLUTE(.); \ 146c978b524SChris Zankel *(.dynsbss) \ 147c978b524SChris Zankel *(.sbss) \ 148c978b524SChris Zankel *(.sbss.*) \ 149c978b524SChris Zankel *(.gnu.linkonce.sb.*) \ 150c978b524SChris Zankel *(.scommon) \ 151c978b524SChris Zankel *(.sbss2) \ 152c978b524SChris Zankel *(.sbss2.*) \ 153c978b524SChris Zankel *(.gnu.linkonce.sb2.*) \ 154c978b524SChris Zankel *(.dynbss) \ 155c978b524SChris Zankel *(.bss) \ 156c978b524SChris Zankel *(.bss.*) \ 157c978b524SChris Zankel *(.gnu.linkonce.b.*) \ 158c978b524SChris Zankel *(COMMON) \ 159c978b524SChris Zankel *(.sram.bss) \ 160c978b524SChris Zankel . = ALIGN(8); \ 161c978b524SChris Zankel _bss_end = ABSOLUTE(.); \ 162c978b524SChris Zankel __bss_end = ABSOLUTE(.); \ 163c978b524SChris Zankel _end = ALIGN(0x8); \ 164c978b524SChris Zankel PROVIDE(end = ALIGN(0x8)); \ 165c978b524SChris Zankel _stack_sentry = ALIGN(0x8); \ 166c978b524SChris Zankel } 167c978b524SChris Zankel 168c978b524SChris Zankel #define SECTION_debug \ 169c978b524SChris Zankel .debug 0 : { *(.debug) } \ 170c978b524SChris Zankel .line 0 : { *(.line) } \ 171c978b524SChris Zankel .debug_srcinfo 0 : { *(.debug_srcinfo) } \ 172c978b524SChris Zankel .debug_sfnames 0 : { *(.debug_sfnames) } \ 173c978b524SChris Zankel .debug_aranges 0 : { *(.debug_aranges) } \ 174c978b524SChris Zankel .debug_pubnames 0 : { *(.debug_pubnames) } \ 175c978b524SChris Zankel .debug_info 0 : { *(.debug_info) } \ 176c978b524SChris Zankel .debug_abbrev 0 : { *(.debug_abbrev) } \ 177c978b524SChris Zankel .debug_line 0 : { *(.debug_line) } \ 178c978b524SChris Zankel .debug_frame 0 : { *(.debug_frame) } \ 179c978b524SChris Zankel .debug_str 0 : { *(.debug_str) } \ 180c978b524SChris Zankel .debug_loc 0 : { *(.debug_loc) } \ 181c978b524SChris Zankel .debug_macinfo 0 : { *(.debug_macinfo) } \ 182c978b524SChris Zankel .debug_weaknames 0 : { *(.debug_weaknames) } \ 183c978b524SChris Zankel .debug_funcnames 0 : { *(.debug_funcnames) } \ 184c978b524SChris Zankel .debug_typenames 0 : { *(.debug_typenames) } \ 185c978b524SChris Zankel .debug_varnames 0 : { *(.debug_varnames) } 186c978b524SChris Zankel 187c978b524SChris Zankel #define SECTION_xtensa \ 188c978b524SChris Zankel .xt.insn 0 : \ 189c978b524SChris Zankel { \ 190c978b524SChris Zankel KEEP (*(.xt.insn)) \ 191c978b524SChris Zankel KEEP (*(.gnu.linkonce.x.*)) \ 192c978b524SChris Zankel } \ 193c978b524SChris Zankel .xt.prop 0 : \ 194c978b524SChris Zankel { \ 195c978b524SChris Zankel KEEP (*(.xt.prop)) \ 196c978b524SChris Zankel KEEP (*(.xt.prop.*)) \ 197c978b524SChris Zankel KEEP (*(.gnu.linkonce.prop.*)) \ 198c978b524SChris Zankel } \ 199c978b524SChris Zankel .xt.lit 0 : \ 200c978b524SChris Zankel { \ 201c978b524SChris Zankel KEEP (*(.xt.lit)) \ 202c978b524SChris Zankel KEEP (*(.xt.lit.*)) \ 203c978b524SChris Zankel KEEP (*(.gnu.linkonce.p.*)) \ 204c978b524SChris Zankel } \ 205c978b524SChris Zankel .xt.profile_range 0 : \ 206c978b524SChris Zankel { \ 207c978b524SChris Zankel KEEP (*(.xt.profile_range)) \ 208c978b524SChris Zankel KEEP (*(.gnu.linkonce.profile_range.*)) \ 209c978b524SChris Zankel } \ 210c978b524SChris Zankel .xt.profile_ranges 0 : \ 211c978b524SChris Zankel { \ 212c978b524SChris Zankel KEEP (*(.xt.profile_ranges)) \ 213c978b524SChris Zankel KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) \ 214c978b524SChris Zankel } \ 215c978b524SChris Zankel .xt.profile_files 0 : \ 216c978b524SChris Zankel { \ 217c978b524SChris Zankel KEEP (*(.xt.profile_files)) \ 218c978b524SChris Zankel KEEP (*(.gnu.linkonce.xt.profile_files.*)) \ 219c978b524SChris Zankel } 220c978b524SChris Zankel 221c978b524SChris Zankel #endif /* _XTENSA_LDSCRIPT_H */ 222