1/*2 * Copyright (C) 2017, 2019 Ken Rabold3 *4 * This file is subject to the terms and conditions of the GNU Lesser5 * General Public License v2.1. See the file LICENSE in the top level6 * directory for more details.7 */89OUTPUT_ARCH( "riscv" )1011ENTRY( _start )1213PHDRS14{15 flash PT_LOAD;16 ram_init PT_LOAD;17 ram PT_NULL;18}1920MEMORY21{22 flash (rx) : ORIGIN = 0x20400000, LENGTH = 0x1fc0000023 ram (rwx) : ORIGIN = 0x80000000, LENGTH = 0x0000400024 itim (rwx) : ORIGIN = 0x08000000, LENGTH = 0x0000200025}2627SECTIONS28{29 __stack_size = DEFINED(__stack_size) ? __stack_size : 256;3031 .init :32 {33 KEEP (*(SORT_NONE(.init)))34 } >flash AT>flash :flash3536 .text :37 {38 *(.text.unlikely .text.unlikely.*)39 *(.text.startup .text.startup.*)40 *(.text .text.*)41 *(.gnu.linkonce.t.*)4243 KEEP(*(.eh_frame*))44 } >flash AT>flash :flash4546 .fini :47 {48 KEEP (*(SORT_NONE(.fini)))49 } >flash AT>flash :flash5051 PROVIDE (__etext = .);52 PROVIDE (_etext = .);53 PROVIDE (etext = .);5455 .rodata :56 {57 *(.rdata)58 *(.rodata .rodata.*)59 *(.gnu.linkonce.r.*)60 } >flash AT>flash :flash6162 . = ALIGN(4);6364 .preinit_array :65 {66 PROVIDE_HIDDEN (__preinit_array_start = .);67 KEEP (*(.preinit_array))68 PROVIDE_HIDDEN (__preinit_array_end = .);69 } >flash AT>flash :flash7071 .init_array :72 {73 PROVIDE_HIDDEN (__init_array_start = .);74 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))75 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))76 PROVIDE_HIDDEN (__init_array_end = .);77 } >flash AT>flash :flash7879 .fini_array :80 {81 PROVIDE_HIDDEN (__fini_array_start = .);82 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))83 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))84 PROVIDE_HIDDEN (__fini_array_end = .);85 } >flash AT>flash :flash8687 .ctors :88 {89 /* gcc uses crtbegin.o to find the start of90 the constructors, so we make sure it is91 first. Because this is a wildcard, it92 doesn't matter if the user does not93 actually link against crtbegin.o; the94 linker won't look for a file to match a95 wildcard. The wildcard also means that it96 doesn't matter which directory crtbegin.o97 is in. */98 KEEP (*crtbegin.o(.ctors))99 KEEP (*crtbegin?.o(.ctors))100 /* We don't want to include the .ctor section from101 the crtend.o file until after the sorted ctors.102 The .ctor section from the crtend file contains the103 end of ctors marker and it must be last */104 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))105 KEEP (*(SORT(.ctors.*)))106 KEEP (*(.ctors))107 } >flash AT>flash :flash108109 .dtors :110 {111 KEEP (*crtbegin.o(.dtors))112 KEEP (*crtbegin?.o(.dtors))113 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))114 KEEP (*(SORT(.dtors.*)))115 KEEP (*(.dtors))116 } >flash AT>flash :flash117118 .lalign :119 {120 . = ALIGN(4);121 PROVIDE( _data_lma = . );122 } >flash AT>flash :flash123124 .dalign :125 {126 . = ALIGN(4);127 PROVIDE( _data = . );128 } >ram AT>flash :ram_init129130 .data :131 {132 *(.ramfunc .ramfunc.*)133 *(.data .data.*)134 *(.gnu.linkonce.d.*)135 . = ALIGN(8);136 PROVIDE( __global_pointer$ = . + 0x800 );137 *(.sdata .sdata.*)138 *(.gnu.linkonce.s.*)139 . = ALIGN(8);140 *(.srodata.cst16)141 *(.srodata.cst8)142 *(.srodata.cst4)143 *(.srodata.cst2)144 *(.srodata .srodata.*)145 } >ram AT>flash :ram_init146147 . = ALIGN(4);148 PROVIDE( _edata = . );149 PROVIDE( edata = . );150151 PROVIDE( _fbss = . );152 PROVIDE( __bss_start = . );153 .bss :154 {155 *(.sbss*)156 *(.gnu.linkonce.sb.*)157 *(.bss .bss.*)158 *(.gnu.linkonce.b.*)159 *(COMMON)160 . = ALIGN(4);161 } >ram AT>ram :ram162163 . = ALIGN(8);164 PROVIDE( _end = . );165 PROVIDE( end = . );166 PROVIDE( _heap_start = . );167168 __StackTop = ORIGIN(ram) + LENGTH(ram);169 __StackLimit = __StackTop - __stack_size;170 PROVIDE(__stack = __StackTop);171}