[fd57015] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup bsp_linker |
---|
| 5 | * |
---|
| 6 | * @brief Linker command base file. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary@gmail.com> |
---|
| 11 | * |
---|
| 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
| 14 | * http://www.rtems.org/license/LICENSE |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | OUTPUT_ARCH (or1k) |
---|
| 18 | |
---|
| 19 | ENTRY (_start) |
---|
[ae739bff] | 20 | STARTUP (start.o) |
---|
[fd57015] | 21 | |
---|
| 22 | /* |
---|
| 23 | * Global symbols that may be defined externally |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | bsp_start_vector_table_begin = 0x1F00; |
---|
| 27 | bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size |
---|
| 28 | : 8260; |
---|
| 29 | /* 8192 for raw vector table, and 17 * 4 for handlers vector. */ |
---|
| 30 | |
---|
| 31 | bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1; |
---|
| 32 | bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1; |
---|
| 33 | bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1; |
---|
| 34 | |
---|
| 35 | bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8; |
---|
| 36 | |
---|
| 37 | SECTIONS { |
---|
| 38 | |
---|
| 39 | .vector : ALIGN_WITH_INPUT { |
---|
| 40 | *(.vector) |
---|
| 41 | . = ALIGN(bsp_vector_table_size); |
---|
| 42 | bsp_section_vector_end = .; |
---|
| 43 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
| 44 | bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin; |
---|
| 45 | bsp_vector_table_begin = bsp_section_vector_begin; |
---|
| 46 | bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size; |
---|
| 47 | |
---|
| 48 | .start : ALIGN_WITH_INPUT { |
---|
| 49 | bsp_section_start_begin = .; |
---|
| 50 | KEEP (*(.bsp_start_text)) |
---|
| 51 | KEEP (*(.bsp_start_data)) |
---|
| 52 | bsp_section_start_end = .; |
---|
| 53 | } > REGION_START AT > REGION_START |
---|
| 54 | bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin; |
---|
| 55 | |
---|
| 56 | .xbarrier : ALIGN_WITH_INPUT { |
---|
| 57 | . = ALIGN (bsp_section_xbarrier_align); |
---|
| 58 | } > REGION_VECTOR AT > REGION_VECTOR |
---|
| 59 | |
---|
| 60 | .text : ALIGN_WITH_INPUT { |
---|
| 61 | bsp_section_text_begin = .; |
---|
| 62 | *(.text.unlikely .text.*_unlikely) |
---|
| 63 | *(.text .stub .text.* .gnu.linkonce.t.*) |
---|
| 64 | /* .gnu.warning sections are handled specially by elf32.em. */ |
---|
| 65 | *(.gnu.warning) |
---|
| 66 | *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) |
---|
| 67 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
| 68 | .init : ALIGN_WITH_INPUT { |
---|
| 69 | KEEP (*(.init)) |
---|
| 70 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
| 71 | .fini : ALIGN_WITH_INPUT { |
---|
| 72 | KEEP (*(.fini)) |
---|
| 73 | bsp_section_text_end = .; |
---|
| 74 | } > REGION_TEXT AT > REGION_TEXT_LOAD |
---|
| 75 | bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin; |
---|
| 76 | bsp_section_text_load_begin = LOADADDR (.text); |
---|
| 77 | bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size; |
---|
| 78 | |
---|
| 79 | .robarrier : ALIGN_WITH_INPUT { |
---|
| 80 | . = ALIGN (bsp_section_robarrier_align); |
---|
| 81 | } > REGION_RODATA AT > REGION_RODATA |
---|
| 82 | |
---|
| 83 | .rodata : ALIGN_WITH_INPUT { |
---|
| 84 | bsp_section_rodata_begin = .; |
---|
| 85 | *(.rodata .rodata.* .gnu.linkonce.r.*) |
---|
| 86 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 87 | .eh_frame : ALIGN_WITH_INPUT { |
---|
| 88 | KEEP (*(.eh_frame)) |
---|
| 89 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 90 | .gcc_except_table : ALIGN_WITH_INPUT { |
---|
| 91 | *(.gcc_except_table .gcc_except_table.*) |
---|
| 92 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 93 | .tdata : ALIGN_WITH_INPUT { |
---|
| 94 | _TLS_Data_begin = .; |
---|
| 95 | *(.tdata .tdata.* .gnu.linkonce.td.*) |
---|
| 96 | _TLS_Data_end = .; |
---|
| 97 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 98 | .tbss : ALIGN_WITH_INPUT { |
---|
| 99 | _TLS_BSS_begin = .; |
---|
| 100 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) |
---|
| 101 | _TLS_BSS_end = .; |
---|
| 102 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 103 | _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; |
---|
| 104 | _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; |
---|
| 105 | _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; |
---|
| 106 | _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; |
---|
| 107 | _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; |
---|
| 108 | _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); |
---|
| 109 | .preinit_array : ALIGN_WITH_INPUT { |
---|
| 110 | PROVIDE_HIDDEN (__preinit_array_start = .); |
---|
| 111 | KEEP (*(.preinit_array)) |
---|
| 112 | PROVIDE_HIDDEN (__preinit_array_end = .); |
---|
| 113 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 114 | .init_array : ALIGN_WITH_INPUT { |
---|
| 115 | PROVIDE_HIDDEN (__init_array_start = .); |
---|
| 116 | KEEP (*(SORT(.init_array.*))) |
---|
| 117 | KEEP (*(.init_array)) |
---|
| 118 | PROVIDE_HIDDEN (__init_array_end = .); |
---|
| 119 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 120 | .fini_array : ALIGN_WITH_INPUT { |
---|
| 121 | PROVIDE_HIDDEN (__fini_array_start = .); |
---|
| 122 | KEEP (*(.fini_array)) |
---|
| 123 | KEEP (*(SORT(.fini_array.*))) |
---|
| 124 | PROVIDE_HIDDEN (__fini_array_end = .); |
---|
| 125 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 126 | .ctors : ALIGN_WITH_INPUT { |
---|
| 127 | /* gcc uses crtbegin.o to find the start of |
---|
| 128 | the constructors, so we make sure it is |
---|
| 129 | first. Because this is a wildcard, it |
---|
| 130 | doesn't matter if the user does not |
---|
| 131 | actually link against crtbegin.o; the |
---|
| 132 | linker won't look for a file to match a |
---|
| 133 | wildcard. The wildcard also means that it |
---|
| 134 | doesn't matter which directory crtbegin.o |
---|
| 135 | is in. */ |
---|
| 136 | KEEP (*crtbegin.o(.ctors)) |
---|
| 137 | KEEP (*crtbegin?.o(.ctors)) |
---|
| 138 | /* We don't want to include the .ctor section from |
---|
| 139 | the crtend.o file until after the sorted ctors. |
---|
| 140 | The .ctor section from the crtend file contains the |
---|
| 141 | end of ctors marker and it must be last */ |
---|
| 142 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) |
---|
| 143 | KEEP (*(SORT(.ctors.*))) |
---|
| 144 | KEEP (*(.ctors)) |
---|
| 145 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 146 | .dtors : ALIGN_WITH_INPUT { |
---|
| 147 | KEEP (*crtbegin.o(.dtors)) |
---|
| 148 | KEEP (*crtbegin?.o(.dtors)) |
---|
| 149 | KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) |
---|
| 150 | KEEP (*(SORT(.dtors.*))) |
---|
| 151 | KEEP (*(.dtors)) |
---|
| 152 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 153 | .data.rel.ro : ALIGN_WITH_INPUT { |
---|
| 154 | *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) |
---|
[21a36ed1] | 155 | *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) |
---|
[fd57015] | 156 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 157 | .jcr : ALIGN_WITH_INPUT { |
---|
| 158 | KEEP (*(.jcr)) |
---|
| 159 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 160 | .interp : ALIGN_WITH_INPUT { |
---|
| 161 | *(.interp) |
---|
| 162 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 163 | .note.gnu.build-id : ALIGN_WITH_INPUT { |
---|
| 164 | *(.note.gnu.build-id) |
---|
| 165 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 166 | .hash : ALIGN_WITH_INPUT { |
---|
| 167 | *(.hash) |
---|
| 168 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 169 | .gnu.hash : ALIGN_WITH_INPUT { |
---|
| 170 | *(.gnu.hash) |
---|
| 171 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 172 | .dynsym : ALIGN_WITH_INPUT { |
---|
| 173 | *(.dynsym) |
---|
| 174 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 175 | .dynstr : ALIGN_WITH_INPUT { |
---|
| 176 | *(.dynstr) |
---|
| 177 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 178 | .gnu.version : ALIGN_WITH_INPUT { |
---|
| 179 | *(.gnu.version) |
---|
| 180 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 181 | .gnu.version_d : ALIGN_WITH_INPUT { |
---|
| 182 | *(.gnu.version_d) |
---|
| 183 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 184 | .gnu.version_r : ALIGN_WITH_INPUT { |
---|
| 185 | *(.gnu.version_r) |
---|
| 186 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 187 | .rel.dyn : ALIGN_WITH_INPUT { |
---|
| 188 | *(.rel.init) |
---|
| 189 | *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) |
---|
| 190 | *(.rel.fini) |
---|
| 191 | *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) |
---|
| 192 | *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) |
---|
| 193 | *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) |
---|
| 194 | *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) |
---|
| 195 | *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) |
---|
| 196 | *(.rel.ctors) |
---|
| 197 | *(.rel.dtors) |
---|
| 198 | *(.rel.got) |
---|
| 199 | *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) |
---|
| 200 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
| 201 | *(.rel.iplt) |
---|
| 202 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
| 203 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
| 204 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
| 205 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 206 | .rela.dyn : ALIGN_WITH_INPUT { |
---|
| 207 | *(.rela.init) |
---|
| 208 | *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) |
---|
| 209 | *(.rela.fini) |
---|
| 210 | *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) |
---|
| 211 | *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) |
---|
| 212 | *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) |
---|
| 213 | *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) |
---|
| 214 | *(.rela.ctors) |
---|
| 215 | *(.rela.dtors) |
---|
| 216 | *(.rela.got) |
---|
| 217 | *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) |
---|
[1fcdd639] | 218 | *(.rela.rtemsroset*) |
---|
| 219 | *(.rela.rtemsrwset*) |
---|
[fd57015] | 220 | PROVIDE_HIDDEN (__rel_iplt_start = .); |
---|
| 221 | PROVIDE_HIDDEN (__rel_iplt_end = .); |
---|
| 222 | PROVIDE_HIDDEN (__rela_iplt_start = .); |
---|
| 223 | *(.rela.iplt) |
---|
| 224 | PROVIDE_HIDDEN (__rela_iplt_end = .); |
---|
| 225 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 226 | .rel.plt : ALIGN_WITH_INPUT { |
---|
| 227 | *(.rel.plt) |
---|
| 228 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 229 | .rela.plt : ALIGN_WITH_INPUT { |
---|
| 230 | *(.rela.plt) |
---|
| 231 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 232 | .plt : ALIGN_WITH_INPUT { |
---|
| 233 | *(.plt) |
---|
| 234 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 235 | .iplt : ALIGN_WITH_INPUT { |
---|
| 236 | *(.iplt) |
---|
| 237 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 238 | .dynamic : ALIGN_WITH_INPUT { |
---|
| 239 | *(.dynamic) |
---|
| 240 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 241 | .got : ALIGN_WITH_INPUT { |
---|
| 242 | *(.got.plt) *(.igot.plt) *(.got) *(.igot) |
---|
| 243 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 244 | .rtemsroset : ALIGN_WITH_INPUT { |
---|
| 245 | /* Special FreeBSD linker set sections */ |
---|
| 246 | __start_set_sysctl_set = .; |
---|
| 247 | *(set_sysctl_*); |
---|
| 248 | __stop_set_sysctl_set = .; |
---|
| 249 | *(set_domain_*); |
---|
| 250 | *(set_pseudo_*); |
---|
| 251 | |
---|
| 252 | KEEP (*(SORT(.rtemsroset.*))) |
---|
| 253 | bsp_section_rodata_end = .; |
---|
| 254 | } > REGION_RODATA AT > REGION_RODATA_LOAD |
---|
| 255 | bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin; |
---|
| 256 | bsp_section_rodata_load_begin = LOADADDR (.rodata); |
---|
| 257 | bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size; |
---|
| 258 | |
---|
[715d616] | 259 | .rwbarrier : ALIGN_WITH_INPUT { |
---|
[fd57015] | 260 | . = ALIGN (bsp_section_rwbarrier_align); |
---|
| 261 | } > REGION_DATA AT > REGION_DATA |
---|
| 262 | |
---|
| 263 | .data : ALIGN_WITH_INPUT { |
---|
| 264 | bsp_section_data_begin = .; |
---|
| 265 | *(.data .data.* .gnu.linkonce.d.*) |
---|
| 266 | SORT(CONSTRUCTORS) |
---|
| 267 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
| 268 | .data1 : ALIGN_WITH_INPUT { |
---|
| 269 | *(.data1) |
---|
| 270 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
| 271 | .rtemsrwset : ALIGN_WITH_INPUT { |
---|
| 272 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
| 273 | bsp_section_data_end = .; |
---|
| 274 | } > REGION_DATA AT > REGION_DATA_LOAD |
---|
| 275 | bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin; |
---|
| 276 | bsp_section_data_load_begin = LOADADDR (.data); |
---|
| 277 | bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size; |
---|
| 278 | |
---|
| 279 | .bss : ALIGN_WITH_INPUT { |
---|
| 280 | bsp_section_bss_begin = .; |
---|
| 281 | *(.dynbss) |
---|
| 282 | *(.bss .bss.* .gnu.linkonce.b.*) |
---|
| 283 | *(COMMON) |
---|
| 284 | bsp_section_bss_end = .; |
---|
| 285 | } > REGION_BSS AT > REGION_BSS |
---|
| 286 | bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin; |
---|
| 287 | |
---|
[e10dec0] | 288 | .noinit (NOLOAD) : ALIGN_WITH_INPUT { |
---|
| 289 | bsp_section_noinit_begin = .; |
---|
[5ed00353] | 290 | *(SORT_BY_NAME (SORT_BY_ALIGNMENT (.noinit*))) |
---|
[e10dec0] | 291 | bsp_section_noinit_end = .; |
---|
| 292 | } > REGION_BSS AT > REGION_BSS |
---|
| 293 | bsp_section_noinit_size = bsp_section_noinit_end - bsp_section_noinit_begin; |
---|
| 294 | |
---|
[715d616] | 295 | .rtemsstack (NOLOAD) : ALIGN_WITH_INPUT{ |
---|
| 296 | *(SORT(.rtemsstack.*)) |
---|
| 297 | } > REGION_WORK AT > REGION_WORK |
---|
| 298 | |
---|
[fd57015] | 299 | .work : ALIGN_WITH_INPUT { |
---|
| 300 | /* |
---|
| 301 | * The work section will occupy the remaining REGION_WORK region and |
---|
| 302 | * contains the RTEMS work space and heap. |
---|
| 303 | */ |
---|
| 304 | bsp_section_work_begin = .; |
---|
| 305 | . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.); |
---|
| 306 | bsp_section_work_end = .; |
---|
| 307 | } > REGION_WORK AT > REGION_WORK |
---|
| 308 | bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin; |
---|
| 309 | |
---|
| 310 | .stack : ALIGN_WITH_INPUT { |
---|
| 311 | bsp_section_stack_end = .; |
---|
| 312 | } > REGION_STACK AT > REGION_STACK |
---|
| 313 | bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end; |
---|
| 314 | |
---|
| 315 | RamBase = ORIGIN (REGION_WORK); |
---|
| 316 | RamSize = LENGTH (REGION_WORK); |
---|
[ffa1153] | 317 | RamEnd = RamBase + RamSize; |
---|
[fd57015] | 318 | WorkAreaBase = bsp_section_work_begin; |
---|
| 319 | HeapSize = 0; |
---|
| 320 | } |
---|