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