Rewrote crt0, init, and chainloading code

start.s, init.c, linker.ld and linker.specs are meant
to be re-used by user applications, should they remove the defines
from init.c and the .chainloader* sections from the linker script
This commit is contained in:
TuxSH
2018-05-07 23:32:45 +02:00
parent 699ddfc043
commit e8306361f0
29 changed files with 848 additions and 185 deletions

View File

@@ -3,19 +3,57 @@ OUTPUT_ARCH(arm)
ENTRY(_start)
/* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY
{
NULL : ORIGIN = 0x00000000, LENGTH = 0x1000
main : ORIGIN = 0x40010000, LENGTH = 0x20000
low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000
}
SECTIONS
{
PROVIDE(__start__ = 0x40010000);
PROVIDE(__start__ = 0x40010000);
PROVIDE(__stack_top__ = 0x40010000);
PROVIDE(__stack_bottom__ = 0x4000C000);
PROVIDE(__heap_start__ = 0);
PROVIDE(__heap_end__ = 0);
. = __start__;
. = ALIGN(32);
.text :
.crt0 :
{
. = ALIGN(32);
/* .init */
KEEP( *(.text.start) )
KEEP( *(.init) )
. = ALIGN(4);
} >main
.chainloader_loadable :
{
. = ALIGN(32);
PROVIDE (__chainloader_start__ = .);
PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable));
KEEP(*(.chainloader.text.start))
build/chainloader.o(.text*)
build/chainloader.o(.rodata*)
build/chainloader.o(.data*)
. = ALIGN(8);
} >low_iram AT>main
.chainloader_bss :
{
. = ALIGN(8);
PROVIDE (__chainloader_bss_start__ = .);
build/chainloader.o(.bss* COMMON)
. = ALIGN(8);
PROVIDE (__chainloader_end__ = .);
} >low_iram AT>main
.text :
{
. = ALIGN(4);
/* .text */
*(.text)
@@ -30,7 +68,7 @@ SECTIONS
/* .fini */
KEEP( *(.fini) )
. = ALIGN(4);
}
} >main
.rodata :
{
@@ -41,14 +79,14 @@ SECTIONS
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4);
}
} >main
.preinit_array ALIGN(4) :
{
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE (__preinit_array_end = .);
}
} >main
.init_array ALIGN(4) :
{
@@ -56,7 +94,7 @@ SECTIONS
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE (__init_array_end = .);
}
} >main
.fini_array ALIGN(4) :
{
@@ -64,7 +102,7 @@ SECTIONS
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE (__fini_array_end = .);
}
} >main
.ctors ALIGN(4) :
{
@@ -72,7 +110,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
} >main
.dtors ALIGN(4) :
{
@@ -80,11 +118,11 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
} >main
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main
__exidx_start = .;
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.data :
@@ -94,19 +132,19 @@ SECTIONS
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
}
} >main
__bss_start__ = ALIGN(32);
.bss :
{
__bss_start__ = ALIGN(32);
*(.dynbss)
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(8);
}
__bss_end__ = .;
__bss_end__ = .;
} >main
__end__ = ABSOLUTE(.) ;
/* ==================