| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* Copyright (c) 2020 StarFiveTech, Inc */ |
| 3 |
OUTPUT_ARCH( "riscv" ) |
| 4 |
|
| 5 |
ENTRY( _start ) |
| 6 |
|
| 7 |
MEMORY |
| 8 |
{ |
| 9 |
rom (rxai!w) : ORIGIN = 0x18000000, LENGTH = 32K |
| 10 |
ram (wxa!ri) : ORIGIN = 0x18008000, LENGTH = 32K |
| 11 |
} |
| 12 |
|
| 13 |
PHDRS |
| 14 |
{ |
| 15 |
rom PT_LOAD; |
| 16 |
ram_init PT_LOAD; |
| 17 |
ram PT_NULL; |
| 18 |
} |
| 19 |
|
| 20 |
SECTIONS |
| 21 |
{ |
| 22 |
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K; |
| 23 |
|
| 24 |
.init : |
| 25 |
{ |
| 26 |
KEEP (*(SORT_NONE(.init))) |
| 27 |
} >rom AT>rom :rom |
| 28 |
|
| 29 |
.text : |
| 30 |
{ |
| 31 |
*(.text.unlikely .text.unlikely.*) |
| 32 |
*(.text.startup .text.startup.*) |
| 33 |
*(.text .text.*) |
| 34 |
*(.gnu.linkonce.t.*) |
| 35 |
} >rom AT>rom :rom |
| 36 |
|
| 37 |
.fini : |
| 38 |
{ |
| 39 |
KEEP (*(SORT_NONE(.fini))) |
| 40 |
} >rom AT>rom :rom |
| 41 |
|
| 42 |
PROVIDE (__etext = .); |
| 43 |
PROVIDE (_etext = .); |
| 44 |
PROVIDE (etext = .); |
| 45 |
|
| 46 |
.rodata : |
| 47 |
{ |
| 48 |
*(.rdata) |
| 49 |
*(.rodata .rodata.*) |
| 50 |
*(.gnu.linkonce.r.*) |
| 51 |
} >rom AT>rom :rom |
| 52 |
|
| 53 |
. = ALIGN(4); |
| 54 |
|
| 55 |
.preinit_array : |
| 56 |
{ |
| 57 |
PROVIDE_HIDDEN (__preinit_array_start = .); |
| 58 |
KEEP (*(.preinit_array)) |
| 59 |
PROVIDE_HIDDEN (__preinit_array_end = .); |
| 60 |
} >rom AT>rom :rom |
| 61 |
|
| 62 |
.init_array : |
| 63 |
{ |
| 64 |
PROVIDE_HIDDEN (__init_array_start = .); |
| 65 |
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) |
| 66 |
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) |
| 67 |
PROVIDE_HIDDEN (__init_array_end = .); |
| 68 |
} >rom AT>rom :rom |
| 69 |
|
| 70 |
.fini_array : |
| 71 |
{ |
| 72 |
PROVIDE_HIDDEN (__fini_array_start = .); |
| 73 |
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) |
| 74 |
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) |
| 75 |
PROVIDE_HIDDEN (__fini_array_end = .); |
| 76 |
} >rom AT>rom :rom |
| 77 |
|
| 78 |
.ctors : |
| 79 |
{ |
| 80 |
/* gcc uses crtbegin.o to find the start of |
| 81 |
the constructors, so we make sure it is |
| 82 |
first. Because this is a wildcard, it |
| 83 |
doesn't matter if the user does not |
| 84 |
actually link against crtbegin.o; the |
| 85 |
linker won't look for a file to match a |
| 86 |
wildcard. The wildcard also means that it |
| 87 |
doesn't matter which directory crtbegin.o |
| 88 |
is in. */ |
| 89 |
KEEP (*crtbegin.o(.ctors)) |
| 90 |
KEEP (*crtbegin?.o(.ctors)) |
| 91 |
/* We don't want to include the .ctor section from |
| 92 |
the crtend.o file until after the sorted ctors. |
| 93 |
The .ctor section from the crtend file contains the |
| 94 |
end of ctors marker and it must be last */ |
| 95 |
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) |
| 96 |
KEEP (*(SORT(.ctors.*))) |
| 97 |
KEEP (*(.ctors)) |
| 98 |
} >rom AT>rom :rom |
| 99 |
|
| 100 |
.dtors : |
| 101 |
{ |
| 102 |
KEEP (*crtbegin.o(.dtors)) |
| 103 |
KEEP (*crtbegin?.o(.dtors)) |
| 104 |
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) |
| 105 |
KEEP (*(SORT(.dtors.*))) |
| 106 |
KEEP (*(.dtors)) |
| 107 |
} >rom AT>rom :rom |
| 108 |
|
| 109 |
.lalign : |
| 110 |
{ |
| 111 |
. = ALIGN(4); |
| 112 |
PROVIDE( _data_lma = . ); |
| 113 |
} >ram AT>rom :rom |
| 114 |
|
| 115 |
.dalign : |
| 116 |
{ |
| 117 |
. = ALIGN(4); |
| 118 |
PROVIDE( _data = . ); |
| 119 |
} >ram AT>rom :rom |
| 120 |
|
| 121 |
.data : |
| 122 |
{ |
| 123 |
*(.data .data.*) |
| 124 |
*(.gnu.linkonce.d.*) |
| 125 |
. = ALIGN(8); |
| 126 |
PROVIDE( __global_pointer$ = . + 0x800 ); |
| 127 |
*(.sdata .sdata.*) |
| 128 |
*(.gnu.linkonce.s.*) |
| 129 |
. = ALIGN(8); |
| 130 |
*(.srodata.cst16) |
| 131 |
*(.srodata.cst8) |
| 132 |
*(.srodata.cst4) |
| 133 |
*(.srodata.cst2) |
| 134 |
*(.srodata .srodata.*) |
| 135 |
} >ram AT>rom :ram_init |
| 136 |
|
| 137 |
. = ALIGN(4); |
| 138 |
PROVIDE( _edata = . ); |
| 139 |
PROVIDE( edata = . ); |
| 140 |
|
| 141 |
PROVIDE( _fbss = . ); |
| 142 |
PROVIDE( __bss_start = . ); |
| 143 |
.bss : |
| 144 |
{ |
| 145 |
*(.sbss*) |
| 146 |
*(.gnu.linkonce.sb.*) |
| 147 |
*(.bss .bss.*) |
| 148 |
*(.gnu.linkonce.b.*) |
| 149 |
*(COMMON) |
| 150 |
. = ALIGN(4); |
| 151 |
} >ram AT>ram :ram |
| 152 |
|
| 153 |
. = ALIGN(8); |
| 154 |
PROVIDE( _end = . ); |
| 155 |
PROVIDE( end = . ); |
| 156 |
|
| 157 |
.stack ORIGIN(ram) + LENGTH(ram) - __stack_size : |
| 158 |
{ |
| 159 |
PROVIDE( _heap_end = . ); |
| 160 |
. = __stack_size; |
| 161 |
PROVIDE( _sp = . ); |
| 162 |
} >ram AT>ram :ram |
| 163 |
} |