/** * @file linkcmds * * GBA BSP linker script */ /* * RTEMS GBA BSP * * Copyright (c) Jeff Frohwein * * Copyright (c) 2003 Jason Wilkins * * Copyright (c) 2004 Markku Puro * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * * http://www.rtems.com/license/LICENSE. * * $Id$ */ /***************************************************************************** * This Linker Script is based on work by Jeff Frohwein and Jason Wilkins ***************************************************************************** * Linker Script v1.3 by Jeff Frohwein * : * This file is released into the public domain * for commercial or non-commercial use with no * restrictions placed upon it. ***************************************************************************** * Copyright 2003, Jason Wilkins. This source code is free for any use except * that this copyright notice and the following disclaimers remain intact when * the source is distributed. There are absolutely no restrictions on use of * object code generated from this source, but the disclaimers remain in force. * * THIS CODE WAS NOT MADE IN ASSOCIATION WITH NINTENDO AND DOES NOT MAKE USE OF * ANY INTELLECTUAL PROPERTY CLAIMED BY NINTENDO. * * GAMEBOY ADVANCE IS A TRADEMARK OF NINTENDO. * * THIS CODE HAS BEEN PROVIDED "AS-IS" WITHOUT A WARRANTY OF ANY KIND, EITHER * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. THE ENTIRE RISK AS TO THE * QUALITY OR PERFORMANCE OF THE CODE IS WITH YOU. * * IN NO EVENT, UNLESS AGREED TO IN WRITING, WILL ANY COPYRIGHT HOLDER, OR ANY * OTHER PARTY, BE HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OR * INABILITY TO USE THIS CODE. * *****************************************************************************/ /* @cond INCLUDE_ASM */ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) /************************************************************************* The linker script MEMORY directive is not used here due to the fact that __ro_start is not always a fixed value. ************************************************************************* MEMORY { rom : ORIGIN = 0x08000000 , LENGTH = 96M iwram : ORIGIN = 0x03000000 , LENGTH = 32K ewram : ORIGIN = 0x02000000 , LENGTH = 256K sram : ORIGIN = 0x0E000000 , LENGTH = 64K } *************************************************************************/ __gba_ewram_start = 0x02000000; __gba_ewram_end = 0x02040000; __gba_iwram_start = 0x03000000; __gba_iwram_end = 0x03008000; __gba_rom_start = 0x08000000; __gba_rom_end = 0x0E000000; __gba_sram_start = 0x0E000000; __gba_sram_end = 0x0E010000; __sp_irq_size = 0x2A0; _stack_size = 0xA00; __irq_vector = __gba_iwram_end - 0x0004; /* 0x03007FFC */ __sp_svc = __gba_iwram_end - 0x0020; /* 0x03007FE0 */ __sp_irq = __gba_iwram_end - 0x0060; /* 0x03007FA0 */ __sp_usr = __sp_irq - __sp_irq_size; /* 0x03007D00 */ __sp_limit = __sp_usr - _stack_size; /* 0x03007300 */ __heap_limit = DEFINED(__gba_multiboot) ? __gba_ewram_end : ( DEFINED(__gba_iwram_bss) ? __sp_limit : __gba_ewram_end ) ; SECTIONS { /*** read-only sections ***/ /************************************************************************* if 'multiboot' allocate prog in __gba_ewram_start (0x02000000-0x0207FFFF) else allocate prog in __gba_rom_start (0x08000000-0x0DFFFFFF) *************************************************************************/ __ro_start = DEFINED(__gba_multiboot) ? __gba_ewram_start : __gba_rom_start ; PROVIDE(__text_start__ = __ro_start ); .text __ro_start : { CREATE_OBJECT_SYMBOLS */start.o(.text) *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .text) *(.stub .text.* .gnu.linkonce.t*) /* * Special FreeBSD sysctl sections. */ . = ALIGN (16); __start_set_sysctl_set = .; *(set_sysctl_*); __stop_set_sysctl_set = ABSOLUTE(.); *(set_domain_*); *(set_pseudo_*); /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7) *(.glue_7t) . = ALIGN(4); } =0xFF .init : { *(.init) . = ALIGN(4); } =0xFF .fini : { *(.fini) . = ALIGN(4); } =0xFF __rodata_start = . ; .rodata : { *(.rodata1) *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .rodata) *(.rodata.* .gnu.linkonce.r*) *(.roda) /* deprecated: for compatibility with objcopyroda */ SORT(CONSTRUCTORS) . = ALIGN(4); } =0xFF __rodata_end = . ; .eh_frame : { KEEP(*(.eh_frame)) . = ALIGN(4); } =0xFF .gcc_except_table : { *(.gcc_except_table) . = ALIGN(4); } =0xFF .ctors : { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP(*crtbegin.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP(*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP(*(SORT(.ctors.*))) KEEP(*(.ctors)) . = ALIGN(4); } =0xFF .dtors : { KEEP(*crtbegin.o(.dtors)) KEEP(*(EXCLUDE_FILE (*crtend.o ) .dtors)) KEEP(*(SORT(.dtors.*))) KEEP(*(.dtors)) . = ALIGN(4); } =0xFF .jcr : { *(.jcr) . = ALIGN(4); } =0xFF /************************************************************************* calculate __ro_end *************************************************************************/ __ro_end = ADDR(.text) + SIZEOF(.text) + SIZEOF(.init) + SIZEOF(.fini) + SIZEOF(.rodata) + SIZEOF(.eh_frame) + SIZEOF(.gcc_except_table) + SIZEOF(.ctors) + SIZEOF(.dtors) + SIZEOF(.jcr); PROVIDE(__text_end__ = __ro_end ); /*** IWRAM ***/ /************************************************************************* allocate iwram in __gba_iwram_start (0x03000000-0x03003FFF) *************************************************************************/ __load_start_iwram = __ro_end; . = __gba_iwram_start ; __iwram_start = . ; PROVIDE(__iwram_start__ = . ); .iwram : AT(__load_start_iwram) { /* put irq_vector_table in stat of iwram */ CREATE_OBJECT_SYMBOLS _irq_vector_table = .; PROVIDE(irq_vector_table = .); . += 4; . = ALIGN(16 * 4); PROVIDE(irq_vector_table_end = .); _irq_vector_table_end = .; *(.iwram .iwram.*) *.iwram.o (.text .rodata .data) . = ALIGN(4); } =0xFF __iwram_end = . ; PROVIDE(__iwram_end__ = . ); __load_stop_iwram = __load_start_iwram + SIZEOF(.iwram); _irq_vector_table_size = _irq_vector_table_end - _irq_vector_table; PROVIDE(_irq_max_vector = _irq_vector_table_size / 4 ); /*** EWRAM ***/ /************************************************************************* if 'multiboot' allocate prog+ewram in __gba_ewram else allocate only ewram in __gba_ewram_start *************************************************************************/ . = DEFINED(__gba_multiboot) ? __load_stop_iwram : __gba_ewram_start ; __load_start_ewram = __load_stop_iwram; __ewram_start = . ; PROVIDE(__ewram_start__ = . ); .ewram : AT(__load_start_ewram) { *(.ewram .ewram.*) *.ewram.o (.text .rodata .data) . = ALIGN(4); } =0xFF __ewram_end = . ; PROVIDE(__ewram_end__ = . ); __load_stop_ewram = __load_start_ewram + SIZEOF(.ewram) ; /************************************************************************* if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram else if 'iwram_data' allocate data in __gba_iwram else allocate data in __gba_ewram *************************************************************************/ . = DEFINED(__gba_multiboot) ? __load_stop_ewram : (DEFINED(__gba_iwram_data) ? __iwram_end : __ewram_end) ; __load_start_data = __load_stop_ewram; __data_start = . ; PROVIDE(__data_start__ = . ); .data : AT(__load_start_data) { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .data) *(.data.* .gnu.linkonce.d.*) *(.data1) *(.tdata .tdata.* .gnu.linkonce.td.*) *(.sdata .sdata.* .gnu.linkonce.s.*) . = ALIGN(4); } =0xFF __data_end = . ; PROVIDE(__data_end__ = . ); __load_stop_data = __load_start_data + SIZEOF(.data); /*** BSS ***/ /************************************************************************* if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram else if 'iwram_data' and 'iwram_bss' allocate iwram+data+bss in __gba_iwram else if !'iwram_data' and 'iwram_bss' allocate iwram+bss in __gba_iwram else allocate data+ewram+bss in __gba_ewram *************************************************************************/ . = DEFINED(__gba_multiboot) ? __load_stop_data : ( DEFINED(__gba_iwram_data) ? (DEFINED(__gba_iwram_bss) ? __data_end : __ewram_end) : (DEFINED(__gba_iwram_bss) ? __iwram_end : __data_end) ) ; __bss_start = . ; PROVIDE(__bss_start__ = . ); .bss : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) *(.sbss .sbss.* .gnu.linkonce.sb.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b*) *(COMMON) . = ALIGN(4); } __bss_end = . ; PROVIDE(__bss_end__ = . ); PROVIDE(_bss_end__ = . ); PROVIDE(_end = . ); PROVIDE(__end__ = _end); PROVIDE(end = _end); /*** debugging info ***/ /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } .comment 0 : { *(.comment) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } } /* @endcond */