*** empty log message ***

This commit is contained in:
Dave Murphy 2006-05-27 13:08:18 +00:00
parent 0f8481b789
commit 71fc99bae1
43 changed files with 9578 additions and 15 deletions

View File

@ -6,8 +6,8 @@
#---------------------------------------------------------------------------------
# specify some urls to download the source packages from
#---------------------------------------------------------------------------------
BINUTILS_VER=2.16.1
GCC_VER=4.1.0
BINUTILS_VER=2.16.93
GCC_VER=4.1.1
NEWLIB_VER=1.14.0
LIBOGC_VER=20050812
LIBGBA_VER=20060518
@ -23,13 +23,14 @@ LIBGBA="libgba-src-$LIBGBA_VER.tar.bz2"
LIBNDS="libnds-src-$LIBNDS_VER.tar.bz2"
ELF2FLT="elf2flt-src-$ELF2FLT_VER.tar.bz2"
SFMIRROR="jaist"
BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/$BINUTILS"
GCC_CORE_URL="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/$GCC_CORE"
GCC_GPP_URL="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/$GCC_GPP"
LIBOGC_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBOGC"
LIBGBA_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBGBA"
LIBNDS_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$LIBNDS"
ELF2FLT_URL="http://osdn.dl.sourceforge.net/sourceforge/devkitpro/$ELF2FLT"
LIBOGC_URL="http://$SFMIRROR.dl.sourceforge.net/sourceforge/devkitpro/$LIBOGC"
LIBGBA_URL="http://$SFMIRROR.dl.sourceforge.net/sourceforge/devkitpro/$LIBGBA"
LIBNDS_URL="http://$SFMIRROR.dl.sourceforge.net/sourceforge/devkitpro/$LIBNDS"
ELF2FLT_URL="http://$SFMIRROR.dl.sourceforge.net/sourceforge/devkitpro/$ELF2FLT"
NEWLIB_URL="ftp://sources.redhat.com/pub/newlib/$NEWLIB"
#---------------------------------------------------------------------------------
@ -46,9 +47,10 @@ do
echo "1: build devkitARM (gba gp32 ds)"
echo "2: build devkitPPC (gamecube)"
echo "3: build devkitPSP (PSP)"
echo "4: build devkitARM eabi (gba gp32 ds)"
read VERSION
if [ "$VERSION" -ne 1 -a "$VERSION" -ne 2 -a "$VERSION" -ne 3 ]
if [ "$VERSION" -ne 1 -a "$VERSION" -ne 2 -a "$VERSION" -ne 3 -a "$VERSION" -ne 4 ]
then
VERSION=0
fi
@ -89,6 +91,14 @@ then
fi
fi
if [ $VERSION -eq 4 ]
then
basedir='dkarm-eabi'
package=devkitARM
builddir=arm-eabi
target=arm-eabi
toolchain=DEVKITARM
fi
DOWNLOAD=0
@ -173,7 +183,7 @@ then
FOUND=1
fi
if [ $VERSION -eq 1 ]
if [ $VERSION -eq 1 -o $VERSION -eq 4 ]
then
if [ ! -f $SRCDIR/$LIBGBA ]
then
@ -228,7 +238,7 @@ else
fi
if [ $VERSION -eq 1 ]
if [ $VERSION -eq 1 -o $VERSION -eq 4 ]
then
$WGET -c $LIBNDS_URL || { echo "Error: Failed to download "$LIBNDS; exit; }
$WGET -c $LIBGBA_URL || { echo "Error: Failed to download "$LIBGBA; exit; }
@ -283,7 +293,7 @@ scriptdir=$(pwd)/$basedir/scripts
BUILDSCRIPTDIR=$(pwd)
echo "Extracting $BINUTILS"
tar -xjvf $SRCDIR/$BINUTILS || { echo "Error extracting "$BINUTILS; exit; }
#tar -xjvf $SRCDIR/$BINUTILS || { echo "Error extracting "$BINUTILS; exit; }
echo "Extracting $GCC_CORE"
tar -xjvf $SRCDIR/$GCC_CORE || { echo "Error extracting "$GCC_CORE; exit; }
@ -302,7 +312,7 @@ then
fi
if [ $VERSION -eq 1 ]
if [ $VERSION -eq 1 -o $VERSION -eq 4 ]
then
echo "Extracting $LIBNDS"
mkdir -p $LIBNDS_SRCDIR
@ -310,7 +320,7 @@ then
echo "Extracting $LIBGBA"
mkdir -p $LIBGBA_SRCDIR
bzip2 -cd $SRCDIR/$LIBGBA | tar -xv -C $LIBGBA_SRCDIR || { echo "Error extracting "$LIBGBA; exit; }
echo "Extracting $NEWLIB"
echo "Extracting $ELF2FLT"
tar -xjvf $SRCDIR/$ELF2FLT || { echo "Error extracting "$ELF2FLT; exit; }
fi

View File

@ -0,0 +1,5 @@
include $(DEVKITARM)/base_rules
all:
$(CC) -x assembler-with-cpp -marm -c $(CRT)_crt0.s -o$(CRT)_crt0.o
$(CC) -x assembler-with-cpp -mthumb -c $(CRT)_crt0.s -o thumb/$(CRT)_crt0.o

198
dkarm-eabi/crtls/ds_arm7.ld Normal file
View File

@ -0,0 +1,198 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03800000, LENGTH = 64K
ewram : ORIGIN = 0x02040000, LENGTH = 4M
}
__ewram_start = ORIGIN(ewram);
__eheap_end = ORIGIN(ewram)+ LENGTH(ewram);
__iwram_start = ORIGIN(iwram);
__iwram_top = ORIGIN(iwram)+ LENGTH(iwram);
__sp_irq = __iwram_top - 0x60;
__sp_svc = __sp_irq - 0x100;
__sp_usr = __sp_svc - 0x100;
__irq_flags = __iwram_top - 8;
__irq_vector = __iwram_top - 4;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.plt : { *(.plt) } >iwram = 0xff
.text : /* ALIGN (4): */
{
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.fini :
{
KEEP (*(.fini))
} >iwram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >iwram
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >iwram
__exidx_end = .;
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >iwram = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >iwram = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >iwram = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
.jcr : { KEEP (*(.jcr)) } >iwram = 0
.got : { *(.got.plt) *(.got) } >iwram = 0
.iwram ALIGN(4) :
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__iwram_end = ABSOLUTE(.) ;
} >iwram = 0xff
.data ALIGN(4) : {
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
__data_end = ABSOLUTE(.) ;
} >iwram = 0xff
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T ds_arm7.ld%s
*startfile:
ds_arm7_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,93 @@
@---------------------------------------------------------------------------------
.section ".init"
.global _start
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
str r0, [r0, #0x208]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
ldr r0, =__bss_start @ Clear BSS section to 0x00
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@ If the user ever returns, return to flash cartridge
mov r0, #0x08000000
bx r0
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
ClrLoop:
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemCheck:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero, so exit
CIDLoop:
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
.end
@---------------------------------------------------------------------------------

235
dkarm-eabi/crtls/ds_arm9.ld Normal file
View File

@ -0,0 +1,235 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
ewram : ORIGIN = 0x02000000, LENGTH = 4M - 4k
dtcm : ORIGIN = 0x0b000000, LENGTH = 16K
itcm : ORIGIN = 0x01000000, LENGTH = 32K
}
__itcm_start = ORIGIN(itcm);
__ewram_end = ORIGIN(ewram) + LENGTH(ewram);
__eheap_end = ORIGIN(ewram) + LENGTH(ewram);
__dtcm_start = ORIGIN(dtcm);
__dtcm_top = ORIGIN(dtcm) + LENGTH(dtcm);
__irq_flags = __dtcm_top - 0x08;
__irq_vector = __dtcm_top - 0x04;
__sp_svc = __dtcm_top - 0x100;
__sp_irq = __sp_svc - 0x100;
__sp_usr = __sp_irq - 0x100;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.plt : { *(.plt) } >ewram = 0xff
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*.itcm*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.fini :
{
KEEP (*(.fini))
} >ewram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ewram
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ewram
__exidx_end = .;
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >ewram = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >ewram = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >ewram = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.jcr : { KEEP (*(.jcr)) } >ewram = 0
.got : { *(.got.plt) *(.got) } >ewram = 0
.ewram ALIGN(4) :
{
__ewram_start = ABSOLUTE(.) ;
*(.ewram)
*ewram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
__data_end = ABSOLUTE(.) ;
} >ewram = 0xff
__dtcm_lma = . ;
.dtcm __dtcm_start : AT (__dtcm_lma)
{
*(.dtcm)
*(.dtcm.*)
. = ALIGN(4);
__dtcm_end = ABSOLUTE(.);
} >dtcm = 0xff
__itcm_lma = __dtcm_lma + SIZEOF(.dtcm);
.itcm __itcm_start : AT (__itcm_lma)
{
*(.itcm)
*itcm.*(.text)
. = ALIGN(4);
__itcm_end = ABSOLUTE(.);
} >itcm = 0xff
.sbss __dtcm_end :
{
__sbss_start = ABSOLUTE(.);
__sbss_start__ = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__sbss_end = ABSOLUTE(.);
} >dtcm
__bss_lma = __itcm_lma + SIZEOF(.itcm) ;
__appended_data = __itcm_lma + SIZEOF(.itcm) ;
.bss __bss_lma : AT (__bss_lma)
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
__bss_end = ABSOLUTE(.) ;
__bss_end__ = __bss_end ;
} >ewram
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T ds_arm9.ld%s
*startfile:
ds_arm9_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,268 @@
#define PAGE_4K (0b01011 << 1)
#define PAGE_8K (0b01100 << 1)
#define PAGE_16K (0b01101 << 1)
#define PAGE_32K (0b01110 << 1)
#define PAGE_64K (0b00111 << 1)
#define PAGE_128K (0b10000 << 1)
#define PAGE_256K (0b10001 << 1)
#define PAGE_512K (0b10010 << 1)
#define PAGE_1M (0b10011 << 1)
#define PAGE_2M (0b10100 << 1)
#define PAGE_4M (0b10101 << 1)
#define PAGE_8M (0b10110 << 1)
#define PAGE_16M (0b10111 << 1)
#define PAGE_32M (0b11000 << 1)
#define PAGE_64M (0b11001 << 1)
#define PAGE_128M (0b11010 << 1)
#define PAGE_256M (0b11011 << 1)
#define PAGE_512M (0b11100 << 1)
#define PAGE_1G (0b11101 << 1)
#define PAGE_2G (0b11110 << 1)
#define PAGE_4G (0b11111 << 1)
#define ITCM_LOAD (1<<19)
#define ITCM_ENABLE (1<<18)
#define DTCM_LOAD (1<<17)
#define DTCM_ENABLE (1<<16)
#define DISABLE_TBIT (1<<15)
#define ROUND_ROBIN (1<<14)
#define ALT_VECTORS (1<<13)
#define ICACHE_ENABLE (1<<12)
#define BIG_ENDIAN (1<<7)
#define DCACHE_ENABLE (1<<2)
#define PROTECT_ENABLE (1<<0)
@---------------------------------------------------------------------------------
.section ".init"
.global _start
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
str r0, [r0, #0x208]
@---------------------------------------------------------------------------------
@ turn the power on for M3
@---------------------------------------------------------------------------------
ldr r1, =0x8203
add r0,r0,#0x304
strh r1, [r0]
ldr r1, =0x00002078 @ disable TCM and protection unit
mcr p15, 0, r1, c1, c0
@---------------------------------------------------------------------------------
@ Protection Unit Setup added by Sasq
@---------------------------------------------------------------------------------
@ Disable cache
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 @ Instruction cache
mcr p15, 0, r0, c7, c6, 0 @ Data cache
@ Wait for write buffer to empty
mcr p15, 0, r0, c7, c10, 4
ldr r0, =__dtcm_start
orr r0,r0,#0x0a
mcr p15, 0, r0, c9, c1,0 @ DTCM base = __dtcm_start, size = 16 KB
mov r0,#0x20
mcr p15, 0, r0, c9, c1,1 @ ITCM base = 0 , size = 32 MB
@---------------------------------------------------------------------------------
@ Setup memory regions similar to Release Version
@---------------------------------------------------------------------------------
@-------------------------------------------------------------------------
@ Region 0 - IO registers
@-------------------------------------------------------------------------
ldr r0,=( PAGE_64M | 0x04000000 | 1)
mcr p15, 0, r0, c6, c0, 0
@-------------------------------------------------------------------------
@ Region 1 - Main Memory
@-------------------------------------------------------------------------
ldr r0,=( PAGE_4M | 0x02000000 | 1)
mcr p15, 0, r0, c6, c1, 0
@-------------------------------------------------------------------------
@ Region 2 - iwram
@-------------------------------------------------------------------------
ldr r0,=( PAGE_32K | 0x037F8000 | 1)
mcr p15, 0, r0, c6, c2, 0
@-------------------------------------------------------------------------
@ Region 3 - DS Accessory (GBA Cart)
@-------------------------------------------------------------------------
ldr r0,=( PAGE_128M | 0x08000000 | 1)
mcr p15, 0, r0, c6, c3, 0
@-------------------------------------------------------------------------
@ Region 4 - DTCM
@-------------------------------------------------------------------------
ldr r0,=__dtcm_start
orr r0,r0,#(PAGE_16K | 1)
mcr p15, 0, r0, c6, c4, 0
@-------------------------------------------------------------------------
@ Region 5 - ITCM
@-------------------------------------------------------------------------
ldr r0,=__itcm_start
orr r0,r0,#(PAGE_32K | 1)
mcr p15, 0, r0, c6, c5, 0
@-------------------------------------------------------------------------
@ Region 6 - System ROM
@-------------------------------------------------------------------------
ldr r0,=( PAGE_32K | 0xFFFF0000 | 1)
mcr p15, 0, r0, c6, c6, 0
@-------------------------------------------------------------------------
@ Region 7 - non cacheable main ram
@-------------------------------------------------------------------------
ldr r0,=( PAGE_4M | 0x02400000 | 1)
mcr p15, 0, r0, c6, c7, 0
@-------------------------------------------------------------------------
@ Write buffer enable
@-------------------------------------------------------------------------
ldr r0,=0b00000110
mcr p15, 0, r0, c3, c0, 0
@-------------------------------------------------------------------------
@ DCache & ICache enable
@-------------------------------------------------------------------------
ldr r0,=0b01000110
ldr r0,=0x42
mcr p15, 0, r0, c2, c0, 0
mcr p15, 0, r0, c2, c0, 1
@-------------------------------------------------------------------------
@ IAccess
@-------------------------------------------------------------------------
ldr r0,=0x36636333
mcr p15, 0, r0, c5, c0, 3
@-------------------------------------------------------------------------
@ DAccess
@-------------------------------------------------------------------------
ldr r0,=0x36333333
mcr p15, 0, r0, c5, c0, 2
@-------------------------------------------------------------------------
@ Enable ICache, DCache, ITCM & DTCM
@-------------------------------------------------------------------------
mrc p15, 0, r0, c1, c0, 0
ldr r1,= ITCM_ENABLE | DTCM_ENABLE | ICACHE_ENABLE | DCACHE_ENABLE | PROTECT_ENABLE
orr r0,r0,r1
mcr p15, 0, r0, c1, c0, 0
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
ldr r1, =__itcm_lma @ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__itcm_start
ldr r4, =__itcm_end
bl CopyMemCheck
ldr r1, =__dtcm_lma @ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
ldr r2, =__dtcm_start
ldr r4, =__dtcm_end
bl CopyMemCheck
ldr r0, =__bss_start @ Clear BSS section
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r0, =__sbss_start @ Clear SBSS section
ldr r1, =__sbss_end
sub r1, r1, r0
bl ClearMem
ldr r1, =fake_heap_end @ set heap end
ldr r0, =__eheap_end
str r0, [r1]
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@ If the user ever returns, go to an infinte loop
ldr r0, =ILoop
ldr r0, [r0]
ldr r1, =0x027FFE78
str r0, [r1]
bx r1
ILoop:
b ILoop
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
ClrLoop:
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemCheck:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero, so exit
CIDLoop:
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
.end
@---------------------------------------------------------------------------------

217
dkarm-eabi/crtls/ds_cart.ld Normal file
View File

@ -0,0 +1,217 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03800000, LENGTH = 64K
ewram : ORIGIN = 0x02000000, LENGTH = 4M
}
__ewram_start = ORIGIN(ewram);
__eheap_end = ORIGIN(ewram)+ LENGTH(ewram);
__iwram_start = ORIGIN(iwram);
__iwram_top = ORIGIN(iwram)+ LENGTH(iwram);
__sp_irq = __iwram_top - 0x60;
__sp_svc = __sp_irq - 0x100;
__sp_usr = __sp_svc - 0x100;
__irq_flags = __iwram_top - 8;
__irq_vector = __iwram_top - 4;
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.plt : { *(.plt) } >rom = 0xff
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.fini :
{
KEEP (*(.fini))
} >rom =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >rom = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >rom = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >rom = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
.jcr : { KEEP (*(.jcr)) } >rom = 0
.got : { *(.got.plt) *(.got) } >rom = 0
__ewram_lma = . ;
.ewram __ewram_start : AT (__ewram_lma)
{
__ewram_start = ABSOLUTE(.) ;
*(.ewram)
*ewram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
} >ewram
__sbss_end = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
__iwram_lma = __ewram_lma + SIZEOF(.ewram) + SIZEOF(.sbss);
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_end = . ;
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >iwram = 0xff
__data_end = . ;
__appended_data = __data_lma + SIZEOF(.data) ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T ds_cart.ld%s
*startfile:
ds_cart_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,160 @@
@---------------------------------------------------------------------------------
.section ".init"
.global _start
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b rom_header_end
@---------------------------------------------------------------------------------
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
.fill 16,1,0 @ Game Title
.byte 0x30,0x31 @ Maker Code (80000B0h)
.byte 0x96 @ Fixed Value (80000B2h)
.byte 0x00 @ Main Unit Code (80000B3h)
.byte 0x00 @ Device Type (80000B4h)
.fill 7,1,0 @ unused
.byte 0x00 @ Software Version No (80000BCh)
.byte 0xf0 @ Complement Check (80000BDh)
.byte 0x00,0x00 @ Checksum (80000BEh)
rom_header_end:
b start_vector @ This branch must be here for proper
@ positioning of the following header.
.GLOBAL __boot_method, __slave_number
__boot_method:
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
__slave_number:
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
.byte 0 @ reserved
.byte 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
@---------------------------------------------------------------------------------
.align 4
.arm
@---------------------------------------------------------------------------------
start_vector:
@---------------------------------------------------------------------------------
mov r0, #0x04000000 @ IME = 0;
str r0, [r0, #0x208]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x13 @ Switch to SVC Mode
msr cpsr, r0
ldr sp, =__sp_svc @ Set SVC stack
mov r0, #0x1F @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
mov r1, #0x42
strb r1, [r7], #1
mov r1, #0x35
strb r1, [r7], #1
mov r1, #0x2B
strb r1, [r7], #1
mov r1, #0x2B
strb r1, [r7], #1
ldr r1, =__data_lma @ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
ldr r2, =__data_start
ldr r4, =__data_end
bl CopyMemChk
ldr r1, =__iwram_lma @ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
ldr r2, =__iwram_start
ldr r4, =__iwram_end
bl CopyMemChk
ldr r0, =__bss_start @ Clear BSS section to 0x00
ldr r1, =__bss_end
sub r1, r1, r0
bl ClearMem
ldr r0, =__sbss_start @ Clear SBSS section to 0x00
ldr r1, =__sbss_end
sub r1, r1, r0
bl ClearMem
ldr r1, =fake_heap_end @ set heap end
ldr r0, =__eheap_end
str r0, [r1]
ldr r3, =_init @ global constructors
bl _call_via_r3
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3 @ jump to user code
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
mov r2, #3 @ Round down to nearest word boundary
add r1, r1, r2 @ Shouldn't be needed
bics r1, r1, r2 @ Clear 2 LSB (and set Z)
bxeq lr @ Quit if copy size is 0
mov r2, #0
@---------------------------------------------------------------------------------
ClrLoop:
@---------------------------------------------------------------------------------
stmia r0!, {r2}
subs r1, r1, #4
bne ClrLoop
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemChk:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r3, r0 @ the length is not a multiple of 4,
bics r3, r3, r0 @ even though it should be.
bxeq lr @ Length is zero so exit
@---------------------------------------------------------------------------------
CIDLoop:
@---------------------------------------------------------------------------------
ldmia r1!, {r0}
stmia r2!, {r0}
subs r3, r3, #4
bne CIDLoop
bx lr
@---------------------------------------------------------------------------------
.align
.pool
@---------------------------------------------------------------------------------
.end
@---------------------------------------------------------------------------------

View File

@ -0,0 +1,56 @@
@---------------------------------------------------------------------------------
@ nintendo e-reader startup code
@---------------------------------------------------------------------------------
@ author : tim schuerewegen
@ version : 1.0
@---------------------------------------------------------------------------------
.section ".init"
.global _start
.align
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b start_vector
.long 0
.long 0x02000000
start_vector:
@ enter thumb mode
adr r0, _start_thumb + 1
bx r0
.thumb
_start_thumb:
@ save return address (rom)
mov r3, lr
@ clear bss section
ldr r0, =__bss_start
ldr r1, =__bss_end
mov r2, #0
_loop_bss_clear:
strb r2, [r0]
add r0, #1
cmp r0, r1
blt _loop_bss_clear
@ set return address (rom)
mov lr, r3
@ jump to main
ldr r3, =main
bx r3
.align
.pool
.end
.align
.pool
.end

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T gba_cart.ld%s
*startfile:
gba_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,315 @@
/* Linker Script Original v1.3 by Jeff Frohwein */
/* v1.0 - Original release */
/* v1.1 - Added proper .data section support */
/* v1.2 - Added support for c++ & iwram overlays */
/* - Major contributions by Jason Wilkins. */
/* v1.3 - .ewram section now can be used when */
/* compiling for MULTIBOOT mode. This fixes */
/* malloc() in DevKitAdvance which depends */
/* on __eheap_start instead of end to define*/
/* the starting location of heap space. */
/* External global variable __gba_iwram_heap*/
/* support added to allow labels end, _end, */
/* & __end__ to point to end of iwram or */
/* the end of ewram. */
/* Additions by WinterMute */
/* v1.4 - .sbss section added for unitialised */
/* data in ewram */
/* v1.5 - padding section added to stop EZF */
/* stripping important data */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* NOTE!!!: This linker script defines the RAM & */
/* ROM start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
/* SEARCH_DIR(/bin/arm); */
/* The linker script function "var1 += var2;" sometimes */
/* reports incorrect values in the *.map file but the */
/* actual value it calculates is usually, if not always, */
/* correct. If you leave out the ". = ALIGN(4);" at the */
/* end of each section then the return value of SIZEOF() */
/* is sometimes incorrect and "var1 += var2;" appears to */
/* not work as well. "var1 += var2" style functions are */
/* avoided below as a result. */
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03000000, LENGTH = 32K
ewram : ORIGIN = 0x02000000, LENGTH = 256K
}
__text_start = 0x8000000;
__eheap_end = 0x2040000;
__iwram_start = 0x3000000;
__iwram_end = 0x3008000;
__sp_irq = __iwram_end - 0x100;
__sp_usr = __sp_irq - 0x100;
__irq_flags = 0x03007ff8;
SECTIONS
{
. = __text_start;
.init :
{
KEEP (*(.init))
. = ALIGN(4);
} >rom =0xff
.plt :
{
*(.plt)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
__text_end = .;
.fini :
{
KEEP (*(.fini))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom =0
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0xff
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >rom = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >rom = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >rom = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.jcr : { KEEP (*(.jcr)) } >rom
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >rom = 0
__iwram_lma = .;
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
__iwram_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram
__bss_end = . ;
__bss_end__ = . ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
} >iwram = 0xff
__iwram_overlay_lma = __data_lma + SIZEOF(.data);
__data_end = .;
__iwram_overlay_start = . ;
OVERLAY ALIGN(4) : NOCROSSREFS AT (__iwram_overlay_lma)
{
.iwram0 { *(.iwram0) . = ALIGN(4);}
.iwram1 { *(.iwram1) . = ALIGN(4);}
.iwram2 { *(.iwram2) . = ALIGN(4);}
.iwram3 { *(.iwram3) . = ALIGN(4);}
.iwram4 { *(.iwram4) . = ALIGN(4);}
.iwram5 { *(.iwram5) . = ALIGN(4);}
.iwram6 { *(.iwram6) . = ALIGN(4);}
.iwram7 { *(.iwram7) . = ALIGN(4);}
.iwram8 { *(.iwram8) . = ALIGN(4);}
.iwram9 { *(.iwram9) . = ALIGN(4);}
}>iwram = 0xff
__ewram_lma = LOADADDR(.iwram0) + SIZEOF(.iwram0)+SIZEOF(.iwram1)+SIZEOF(.iwram2)+SIZEOF(.iwram3)+SIZEOF(.iwram4)+SIZEOF(.iwram5)+SIZEOF(.iwram6)+SIZEOF(.iwram7)+SIZEOF(.iwram8)+SIZEOF(.iwram9);
__iwram_overlay_end = . ;
__iheap_start = . ;
__ewram_start = 0x2000000;
.ewram __ewram_start : AT (__ewram_lma)
{
*(.ewram)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
}>ewram = 0xff
__ewram_overlay_lma = __ewram_lma + SIZEOF(.ewram);
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
} >ewram
__sbss_end = .;
__ewram_end = . ;
__ewram_overlay_start = . ;
OVERLAY ALIGN(4): NOCROSSREFS AT (__ewram_overlay_lma)
{
.ewram0 { *(.ewram0) . = ALIGN(4);}
.ewram1 { *(.ewram1) . = ALIGN(4);}
.ewram2 { *(.ewram2) . = ALIGN(4);}
.ewram3 { *(.ewram3) . = ALIGN(4);}
.ewram4 { *(.ewram4) . = ALIGN(4);}
.ewram5 { *(.ewram5) . = ALIGN(4);}
.ewram6 { *(.ewram6) . = ALIGN(4);}
.ewram7 { *(.ewram7) . = ALIGN(4);}
.ewram8 { *(.ewram8) . = ALIGN(4);}
.ewram9 { *(.ewram9) . = ALIGN(4);}
}>ewram = 0xff
__pad_lma = LOADADDR(.ewram0) + SIZEOF(.ewram0)+SIZEOF(.ewram1)+SIZEOF(.ewram2)+SIZEOF(.ewram3)+SIZEOF(.ewram4)+SIZEOF(.ewram5)+SIZEOF(.ewram6)+SIZEOF(.ewram7)+SIZEOF(.ewram8)+SIZEOF(.ewram9);
/* EZF Advance strips trailing 0xff bytes, add a pad section so nothing important is removed */
.pad ALIGN(4) : AT (__pad_lma)
{
LONG(0x52416b64)
LONG(0x4d)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} = 0xff
__ewram_overlay_end = . ;
__eheap_start = . ;
_end = .;
__end__ = _end ; /* v1.3 */
PROVIDE (end = _end); /* v1.3 */
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

251
dkarm-eabi/crtls/gba_crt0.s Normal file
View File

@ -0,0 +1,251 @@
.section ".init"
.global _start
.align
.arm
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b rom_header_end
.fill 156,1,0 @ Nintendo Logo Character Data (8000004h)
.fill 16,1,0 @ Game Title
.byte 0x30,0x31 @ Maker Code (80000B0h)
.byte 0x96 @ Fixed Value (80000B2h)
.byte 0x00 @ Main Unit Code (80000B3h)
.byte 0x00 @ Device Type (80000B4h)
.fill 7,1,0 @ unused
.byte 0x00 @ Software Version No (80000BCh)
.byte 0xf0 @ Complement Check (80000BDh)
.byte 0x00,0x00 @ Checksum (80000BEh)
@---------------------------------------------------------------------------------
rom_header_end:
@---------------------------------------------------------------------------------
b start_vector @ This branch must be here for proper
@ positioning of the following header.
.GLOBAL __boot_method, __slave_number
@---------------------------------------------------------------------------------
__boot_method:
@---------------------------------------------------------------------------------
.byte 0 @ boot method (0=ROM boot, 3=Multiplay boot)
@---------------------------------------------------------------------------------
__slave_number:
@---------------------------------------------------------------------------------
.byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3)
.byte 0 @ reserved
.byte 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.word 0 @ reserved
.global start_vector
.align
@---------------------------------------------------------------------------------
start_vector:
@---------------------------------------------------------------------------------
mov r0, #0x4000000 @ REG_BASE
str r0, [r0, #0x208]
mov r0, #0x12 @ Switch to IRQ Mode
msr cpsr, r0
ldr sp, =__sp_irq @ Set IRQ stack
mov r0, #0x1f @ Switch to System Mode
msr cpsr, r0
ldr sp, =__sp_usr @ Set user stack
@---------------------------------------------------------------------------------
@ Enter Thumb mode
@---------------------------------------------------------------------------------
add r0, pc, #1
bx r0
.thumb
ldr r0, =__text_start
lsl r0, #5 @ Was code compiled at 0x08000000 or higher?
bcs DoEWRAMClear @ yes, you can not run it in external WRAM
mov r0, pc
lsl r0, #5 @ Are we running from ROM (0x8000000 or higher) ?
bcc SkipEWRAMClear @ No, so no need to do a copy.
@---------------------------------------------------------------------------------
@ We were started in ROM, silly emulators. :P
@ So we need to copy to ExWRAM.
@---------------------------------------------------------------------------------
mov r2, #2
lsl r2, r2, #24 @ r2= 0x02000000
ldr r3, =__end__ @ last ewram address
sub r3, r2 @ r3= actual binary size
mov r6, r2 @ r6= 0x02000000
lsl r1, r2, #2 @ r1= 0x08000000
bl CopyMem
bx r6 @ Jump to the code to execute
@---------------------------------------------------------------------------------
DoEWRAMClear: @ Clear External WRAM to 0x00
@---------------------------------------------------------------------------------
mov r1, #0x40
lsl r1, #12 @ r1 = 0x40000
lsl r0, r1, #7 @ r0 = 0x2000000
bl ClearMem
@---------------------------------------------------------------------------------
SkipEWRAMClear: @ Clear Internal WRAM to 0x00
@---------------------------------------------------------------------------------
@---------------------------------------------------------------------------------
@ Clear BSS section to 0x00
@---------------------------------------------------------------------------------
ldr r0, =__bss_start
ldr r1, =__bss_end
sub r1, r0
bl ClearMem
@---------------------------------------------------------------------------------
@ Clear SBSS section to 0x00
@---------------------------------------------------------------------------------
ldr r0, =__sbss_start
ldr r1, =__sbss_end
sub r1, r0
bl ClearMem
@---------------------------------------------------------------------------------
@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1, =__data_lma
ldr r2, =__data_start
ldr r4, =__data_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1,= __iwram_lma
ldr r2,= __iwram_start
ldr r4,= __iwram_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r2,= __load_stop_iwram0
ldr r1,= __load_start_iwram0
sub r3, r2, r1 @ Is there any data to copy?
beq CIW0Skip @ no
ldr r2,= __iwram_overlay_start
bl CopyMem
@---------------------------------------------------------------------------------
CIW0Skip:
@---------------------------------------------------------------------------------
@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r1, =__ewram_lma
ldr r2, =__ewram_start
ldr r4, =__ewram_end
bl CopyMemChk
@---------------------------------------------------------------------------------
@ Copy external work ram overlay 0 (ewram0 section) from LMA to VMA (ROM to RAM)
@---------------------------------------------------------------------------------
ldr r2, =__load_stop_ewram0
ldr r1, =__load_start_ewram0
sub r3, r2, r1 @ Is there any data to copy?
beq CEW0Skip @ no
ldr r2, =__ewram_overlay_start
bl CopyMem
@---------------------------------------------------------------------------------
CEW0Skip:
@---------------------------------------------------------------------------------
@ set heap end
@---------------------------------------------------------------------------------
ldr r1, =fake_heap_end
ldr r0, =__eheap_end
str r0, [r1]
@---------------------------------------------------------------------------------
@ global constructors
@---------------------------------------------------------------------------------
ldr r3, =_init
bl _call_via_r3
@---------------------------------------------------------------------------------
@ Jump to user code
@---------------------------------------------------------------------------------
mov r0, #0 @ int argc
mov r1, #0 @ char *argv[]
ldr r3, =main
bl _call_via_r3
@---------------------------------------------------------------------------------
@ Clear memory to 0x00 if length != 0
@---------------------------------------------------------------------------------
@ r0 = Start Address
@ r1 = Length
@---------------------------------------------------------------------------------
ClearMem:
@---------------------------------------------------------------------------------
mov r2,#3 @ These commands are used in cases where
add r1,r2 @ the length is not a multiple of 4,
bic r1,r2 @ even though it should be.
beq ClearMX @ Length is zero so exit
mov r2,#0
@---------------------------------------------------------------------------------
ClrLoop:
@---------------------------------------------------------------------------------
stmia r0!, {r2}
sub r1,#4
bne ClrLoop
@---------------------------------------------------------------------------------
ClearMX:
@---------------------------------------------------------------------------------
bx lr
@---------------------------------------------------------------------------------
@ Copy memory if length != 0
@---------------------------------------------------------------------------------
@ r1 = Source Address
@ r2 = Dest Address
@ r4 = Dest Address + Length
@---------------------------------------------------------------------------------
CopyMemChk:
@---------------------------------------------------------------------------------
sub r3, r4, r2 @ Is there any data to copy?
@---------------------------------------------------------------------------------
@ Copy memory
@---------------------------------------------------------------------------------
@ r1 = Source Address
@ r2 = Dest Address
@ r3 = Length
@---------------------------------------------------------------------------------
CopyMem:
@---------------------------------------------------------------------------------
mov r0, #3 @ These commands are used in cases where
add r3, r0 @ the length is not a multiple of 4,
bic r3, r0 @ even though it should be.
beq CIDExit @ Length is zero so exit
@---------------------------------------------------------------------------------
CIDLoop:
@---------------------------------------------------------------------------------
ldmia r1!, {r0}
stmia r2!, {r0}
sub r3, #4
bne CIDLoop
@---------------------------------------------------------------------------------
CIDExit:
@---------------------------------------------------------------------------------
bx lr
.align
.pool
.end

View File

@ -0,0 +1,50 @@
/***********************************/
/* NINTENDO E-READER LINKER SCRIPT */
/***********************************/
/* Author : Tim Schuerewegen */
/* Version : 1.0 */
/***********************************/
OUTPUT_FORMAT( "elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH( arm)
ENTRY( _start)
SECTIONS
{
. = 0x02000000;
.init :
{
*(.init)
. = ALIGN(4);
} = 0xff
.text :
{
*(.text)
. = ALIGN(4);
} = 0xff
.rodata :
{
*(.rodata)
. = ALIGN(4);
} = 0xff
.data :
{
*(.data)
. = ALIGN(4);
} = 0xff
.bss :
{
__bss_start = .;
*(.bss)
. = ALIGN(4);
}
__bss_end = .;
__end = .;
}

View File

@ -0,0 +1,8 @@
%rename link old_link
%rename endfile old_endfile
*link:
-T gba_er.ld%s %(old_link)
*startfile:
er_crt0%O%s

301
dkarm-eabi/crtls/gba_mb.ld Normal file
View File

@ -0,0 +1,301 @@
/* Linker Script Original v1.3 by Jeff Frohwein */
/* v1.0 - Original release */
/* v1.1 - Added proper .data section support */
/* v1.2 - Added support for c++ & iwram overlays */
/* - Major contributions by Jason Wilkins. */
/* v1.3 - .ewram section now can be used when */
/* compiling for MULTIBOOT mode. This fixes */
/* malloc() in DevKitAdvance which depends */
/* on __eheap_start instead of end to define*/
/* the starting location of heap space. */
/* External global variable __gba_iwram_heap*/
/* support added to allow labels end, _end, */
/* & __end__ to point to end of iwram or */
/* the end of ewram. */
/* Additions by WinterMute */
/* v1.4 - .sbss section added for unitialised */
/* data in ewram */
/* v1.5 - padding section added to stop EZF */
/* stripping important data */
/* v1.6 - added memory sections */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* NOTE!!!: This linker script defines the RAM & */
/* ROM start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY {
rom : ORIGIN = 0x08000000, LENGTH = 32M
iwram : ORIGIN = 0x03000000, LENGTH = 32K
ewram : ORIGIN = 0x02000000, LENGTH = 256K
}
__text_start = 0x2000000 ;
__eheap_end = 0x2040000;
__iwram_start = 0x3000000;
__iwram_end = 0x3008000;
__sp_irq = __iwram_end - 0x100;
__sp_usr = __sp_irq - 0x100;
__irq_flags = 0x03007ff8;
SECTIONS
{
. = __text_start;
.init :
{
KEEP (*(.init))
. = ALIGN(4);
} >ewram =0xff
.plt :
{
*(.plt)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram
.text ALIGN (4):
{
*(EXCLUDE_FILE (*.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
__text_end = .;
.fini :
{
KEEP (*(.fini))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram =0
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >ewram = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >ewram = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >ewram = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.jcr : { KEEP (*(.jcr)) } >ewram
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0
__iwram_lma = .;
.iwram __iwram_start : AT (__iwram_lma)
{
__iwram_start = ABSOLUTE(.) ;
*(.iwram)
*iwram.*(.text)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__data_lma = __iwram_lma + SIZEOF(.iwram) ;
__iwram_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
__bss_start__ = ABSOLUTE(.);
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
}
__bss_end = . ;
__bss_end__ = . ;
.data ALIGN(4) : AT (__data_lma)
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >iwram = 0xff
__iwram_overlay_lma = __data_lma + SIZEOF(.data);
__data_end = .;
PROVIDE (edata = .);
__iwram_overlay_start = . ;
OVERLAY ALIGN(4) : NOCROSSREFS AT (__iwram_overlay_lma)
{
.iwram0 { *(.iwram0) . = ALIGN(4);}
.iwram1 { *(.iwram1) . = ALIGN(4);}
.iwram2 { *(.iwram2) . = ALIGN(4);}
.iwram3 { *(.iwram3) . = ALIGN(4);}
.iwram4 { *(.iwram4) . = ALIGN(4);}
.iwram5 { *(.iwram5) . = ALIGN(4);}
.iwram6 { *(.iwram6) . = ALIGN(4);}
.iwram7 { *(.iwram7) . = ALIGN(4);}
.iwram8 { *(.iwram8) . = ALIGN(4);}
.iwram9 { *(.iwram9) . = ALIGN(4);}
} >iwram = 0xff
__ewram_lma = LOADADDR(.iwram0) + SIZEOF(.iwram0)+SIZEOF(.iwram1)+SIZEOF(.iwram2)+SIZEOF(.iwram3)+SIZEOF(.iwram4)+SIZEOF(.iwram5)+SIZEOF(.iwram6)+SIZEOF(.iwram7)+SIZEOF(.iwram8)+SIZEOF(.iwram9);
__iwram_overlay_end = . ;
__iheap_start = . ;
/* v1.3 */
__ewram_start = __ewram_lma ;
.ewram __ewram_start : AT (__ewram_lma)
{
*(.ewram)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ewram = 0xff
__ewram_overlay_lma = __ewram_lma + SIZEOF(.ewram);
.sbss ALIGN(4):
{
__sbss_start = ABSOLUTE(.);
*(.sbss)
. = ALIGN(4);
}
__sbss_end = .;
__ewram_end = . ;
__ewram_overlay_start = . ;
OVERLAY ALIGN(4): NOCROSSREFS AT (__ewram_overlay_lma)
{
.ewram0 { *(.ewram0) . = ALIGN(4);}
.ewram1 { *(.ewram1) . = ALIGN(4);}
.ewram2 { *(.ewram2) . = ALIGN(4);}
.ewram3 { *(.ewram3) . = ALIGN(4);}
.ewram4 { *(.ewram4) . = ALIGN(4);}
.ewram5 { *(.ewram5) . = ALIGN(4);}
.ewram6 { *(.ewram6) . = ALIGN(4);}
.ewram7 { *(.ewram7) . = ALIGN(4);}
.ewram8 { *(.ewram8) . = ALIGN(4);}
.ewram9 { *(.ewram9) . = ALIGN(4);}
} >ewram = 0xff
__ewram_overlay_end = . ;
__eheap_start = . ;
_end = .;
__end__ = _end ; /* v1.3 */
PROVIDE (end = _end); /* v1.3 */
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
-T gba_mb.ld%s %(old_link)
*startfile:
gba_crt0%O%s crti%O%s crtbegin%O%s

167
dkarm-eabi/crtls/gp32.ld Normal file
View File

@ -0,0 +1,167 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY
{
ram : ORIGIN = 0xc000000, LENGTH = 8M
}
SECTIONS
{
.init :
{
__text_start = . ;
KEEP (*(.init))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.plt : { *(.plt) } >ram = 0xff
.text : /* ALIGN (4): */
{
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
.fini :
{
KEEP (*(.fini))
} >ram =0xff
__text_end = . ;
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) } >ram = 0xff
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) } >ram = 0xff
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) } >ram = 0xff
PROVIDE (__fini_array_end = .);
.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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.jcr : { KEEP (*(.jcr)) } >ram = 0
.got : { *(.got.plt) *(.got) } >ram = 0
__ro_end = . ;
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
/* __bss_start__ = ABSOLUTE(.); */
*(.dynbss)
*(.gnu.linkonce.b*)
*(.bss*)
*(COMMON)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} > ram
__bss_end = . ;
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T gp32.ld%s
*startfile:
gp32_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,74 @@
.section ".init"
.code 32
.align
.global _start
@---------------------------------------------------------------------------------
_start:
@---------------------------------------------------------------------------------
b _start2
@---------------------------------------------------------------------------------
@ AXF addresses
@---------------------------------------------------------------------------------
_text_start:
.word __text_start
_ro_end:
.word __ro_end
_data_start:
.word __data_start
.word __bss_end
_bss_start:
.word __bss_start
_bss_end:
.word __bss_end
@---------------------------------------------------------------------------------
@ GamePark magic sequence
@---------------------------------------------------------------------------------
.word 0x44450011
.word 0x44450011
.word 0x01234567
.word 0x12345678
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
@---------------------------------------------------------------------------------
_start2:
@---------------------------------------------------------------------------------
mrs r0, CPSR
orr r0, r0, #0xC0
msr CPSR_ctl, r0
mrs r0, CPSR
bic r0, r0, #0xC0
orr r0, r0, #0x40
msr CPSR_ctl,r0
@---------------------------------------------------------------------------------
@ global constructors
@---------------------------------------------------------------------------------
ldr r3,=_call_main
mov lr,r3
ldr r3,=_init
bx r3
@---------------------------------------------------------------------------------
@ Jump to user code
@---------------------------------------------------------------------------------
_call_main:
@---------------------------------------------------------------------------------
mov lr, #0
ldr r3, =main
bx r3
.pool
.end

View File

@ -0,0 +1,198 @@
/* GP32 Linker Script v1.2 by Jeff F */
/* v1.0 - Original release */
/* v1.1 - Cleaned up and added MEMORY command */
/* v1.2 - DJWillis - Added propper .init and */
/* .fini for GCC 3.3.2 and above */
/* */
/* This file is released into the public domain */
/* for commercial or non-commercial use with no */
/* restrictions placed upon it. */
/* */
/* NOTE!!!: This linker script defines the RAM */
/* start addresses. In order for it to work */
/* properly, remove -Ttext and -Tbss linker */
/* options from your makefile if they are */
/* present. */
/* */
/* You can use the following to view section */
/* addresses in your .elf file: */
/* objdump -h file.elf */
/* */
/* Please note that empty sections may incorrectly*/
/* list the lma address as the vma address for */
/* some versions of objdump. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
/* SEARCH_DIR(/bin/arm); */
/* Then use it like this: IWRAMHEAP */
/* The linker script function "var1 += var2;" sometimes */
/* reports incorrect values in the *.map file but the */
/* actual value it calculates is usually, if not always, */
/* correct. If you leave out the ". = ALIGN(4);" at the */
/* end of each section then the return value of SIZEOF() */
/* is sometimes incorrect and "var1 += var2;" appears to */
/* not work as well. "var1 += var2" style functions are */
/* avoided below as a result. */
/* The linker script MEMORY directive is not used here due */
/* to the fact that __text_start is not always a fixed value. */
MEMORY
{
ram : ORIGIN = 0xc000000, LENGTH = 8M
}
SECTIONS
{
.text : /* ALIGN (4): */
{
__text_start = . ;
*(EXCLUDE_FILE (*text.iwram*) .text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__text_end = . ;
.init :
{
*(.init)
} > ram = 0xff
.jcr :
{
*(.jcr)
} > ram = 0xff
.fini :
{
*(.fini)
} > ram = 0xff
.rodata :
{
*(.rodata)
*all.rodata*(*)
*(.roda)
*(.rodata.*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 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))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.eh_frame :
{
KEEP (*(.eh_frame))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
.gcc_except_table :
{
*(.gcc_except_table)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0
__ro_end = . ;
.data ALIGN(4) :
{
__data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >ram = 0xff
__data_end = . ;
.bss ALIGN(4) :
{
__bss_start = ABSOLUTE(.);
/* __bss_start__ = ABSOLUTE(.); */
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
*(.bss*)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} > ram
__bss_end = . ;
__eheap_start = . ; /* Needed by DevKitAdvance. Start of malloc() heap for DKA. */
_end = . ;
__end__ = . ;
PROVIDE (end = _end);
__eheap_end = . ;
/* 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) }
.comment 0 : { *(.comment) }
/* 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) }
/* 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) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

View File

@ -0,0 +1,12 @@
%rename link old_link
%rename link_gcc_c_sequence old_gcc_c_sequence
*link_gcc_c_sequence:
%(old_gcc_c_sequence) --start-group -lsysbase -lc --end-group
*link:
%(old_link) -T gp32_gpsdk.ld%s
*startfile:
gp32_gpsdk_crt0%O%s crti%O%s crtbegin%O%s

View File

@ -0,0 +1,246 @@
@****************************************************
@* gp32 crt0.S v1.0 by Jeff F *
@****************************************************
@ v1.0 - Original release
@
@ This file is released into the public domain for commercial
@ or non-commercial usage with no restrictions placed upon it.
.TEXT
@ Note: Normally it is the job of crt0.S to clear the BSS
@ (Zero Initialized) section to 0x00, but in the case of
@ the gp32 we do not have to do this because it is done
@ by the gp32 bios after it loads the app.
@ The official sdt dev kit uses 'Main ()' as the entry
@ point. If you would rather use 'main ()' instead then
@ comment out the next line.
@
@ You have to use 'main ()' at some point in your program
@ if you want to do c++ code. GCC will do a call to constructor
@ setup before executing 'main ()'. Using 'main ()' also increases
@ your program size by ~5500 bytes.
@ .equ __OfficialEntry, 1
@ The official sdt dev kit initializes various things in init.o
@ Crt0.S performs similar tasks for compatibility. If you don't
@ wish to use the official libs, or those that are compatible,
@ then you need to comment out the next line to prevent link errors.
.equ __OfficialInits, 1
.GLOBAL _start
_start:
.ALIGN
.CODE 32
@ Start Vector
b _GpInit
.word __text_start @ Start of text (Read Only) section
_roe: .word __ro_end @ End "
_rws: .word __data_start @ Start of data (Read/Write) section
.word __bss_end @ End of bss (this is the way sdt does it for some reason)
_zis: .word __bss_start @ Start of bss (Zero Initialized) section
_zie: .word __bss_end @ End "
.word 0x44450011
.word 0x44450011
.word 0x01234567
.word 0x12345678
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
.word 0x23456789
.word 0x34567890
.word 0x45678901
.word 0x56789012
_GpInit:
mrs r0,CPSR
orr r0,r0,#0xc0
msr CPSR_fsxc,r0
.ifdef __OfficialInits
@ Call function in user_init.s
@ bl asm_user_entry
@ Get pointer to GpSurfaceSet routine
mov r0,#0
swi 0xb
ldr r1,=GpSurfaceSet
ldr r2,=GpSurfaceFlip
str r0,[r1]
str r0,[r2]
@ Get time passed
mov r0,#6
swi 0xb
ldr r1,=_timepassed
str r0,[r1]
@ Get button stuff
mov r0,#0
swi 0x10
ldr r2,=_reg_io_key_a
ldr r3,=_reg_io_key_b
str r0,[r2]
str r1,[r3]
@ Set heap start location
ldr r0,_zie
ldr r1,=HEAPSTART
str r0,[r1]
@ Set heap end location
mov r0,#5
swi 0xb
ldr r1,=HEAPEND
sub r0,r0,#255
bic r0,r0,#3
str r0,[r1]
@ Set App Argument
swi 0x15
mov r10,r0
mov r11,r1 @ possibly not needed but left in anyway
mrs r0,CPSR
bic r0,r0,#192
orr r0,r0,#64
msr CPSR_fsxc,r0
mov r0,r10
mov r1,r11 @ possibly not needed but left in anyway
.endif
@ Jump to Main ()
.ifdef __OfficialEntry
ldr r3,=Main
.else
ldr r3,=main
.endif
bx r3 @ Init.o uses 'mov pc,r3' but
@ 'bx r3' is used here instead. This way
@ the main function can be ARM or Thumb.
.ifdef __OfficialInits
swi 0x12
orr r1,r1,r2
and r1,r1,r3
eor r1,r1,r4
mov r5,r1,lsr #4
add r1,r1,r7
sub r7,r7,r1
mov r8,#0
mov pc,r8
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
b .
nop
nop
nop
nop
nop
nop
.GLOBAL _fw_init_for_dbg
_fw_init_for_dbg:
stmdb sp!,{r0-r12}
mov r10,lr
mov r11,sp
bic r0,r0,#31 @ 0x1f
orr r1,r0,#17 @ 0x11
orr r2,r0,#19 @ 0x13
msr cpsr_cxsf,r1
mov r12,#4
add r12,r12,pc
msr cpsr_cxsf,r2
swi 0x1ff
@ bl asm_user_entry_path
mov r0,r11
mov r1,r10
add r0,r0,#52
ldr r2,[r0]
mov lr,r1
stmdb sp!,{r2}
stmdb sp!,{r0-r12,lr}
@ Copy RW Base - ZI Base
ldr r0,=_roe @ |Image$$RO$$Limit|
ldr r3,=_zis @ |Image$$ZI$$Base|
ldr r2,=_rws @ |Image$$RW$$Base|
sub r3,r3,r2
CopyRWData:
cmp r3,#36
blt CopyRWData2
ldmia r0!,{r4-r12}
stmia r2!,{r4-r12}
sub r3,r3,#36
b CopyRWData
CopyRWData2:
cmp r3,#0
ble CopyRWData3
ldr r4,[r0],#4
str r4,[r2],#4
sub r3,r3,#4
b CopyRWData2
CopyRWData3:
@ Clear ZI section
ldr r1,=_zie @ |Image$$ZI$$Limit|
ldr r0,=_zis @ |Image$$ZI$$Base|
mov r2,#0
mov r3,r2
mov r4,r2
mov r5,r2
mov r6,r2
mov r7,r2
mov r8,r2
mov r9,r2
mov r10,r2
mov r11,r2
mov r12,r2
CopyZIData:
stmia r0!,{r2-r12}
cmp r0,r1
blt CopyZIData
ldmia sp!,{r0-r12,pc}
.endif
.ALIGN
.POOL
.END

View File

@ -0,0 +1,16 @@
diff -Nbaur --exclude=*.info* binutils-2.16.1/bfd/doc/chew.c binutils-2.16.1-arm/bfd/doc/chew.c
--- binutils-2.16.1/bfd/doc/chew.c Thu Mar 3 11:41:02 2005
+++ binutils-2.16.1-arm/bfd/doc/chew.c Mon Sep 19 03:38:45 2005
@@ -91,6 +91,12 @@
#define DEF_SIZE 5000
#define STACK 50
+#ifdef __MINGW32__
+/* Prevent \r\n\ line endings */
+#include <fcntl.h>
+unsigned int _CRT_fmode = _O_BINARY;
+#endif
+
int internal_wanted;
int internal_mode;

View File

@ -0,0 +1,16 @@
diff -Nbaur --exclude=*.info* binutils-2.16.1/bfd/doc/chew.c binutils-2.16.1-arm/bfd/doc/chew.c
--- binutils-2.16.1/bfd/doc/chew.c Thu Mar 3 11:41:02 2005
+++ binutils-2.16.1-arm/bfd/doc/chew.c Mon Sep 19 03:38:45 2005
@@ -91,6 +91,12 @@
#define DEF_SIZE 5000
#define STACK 50
+#ifdef __MINGW32__
+/* Prevent \r\n\ line endings */
+#include <fcntl.h>
+unsigned int _CRT_fmode = _O_BINARY;
+#endif
+
int internal_wanted;
int internal_mode;

View File

@ -0,0 +1,64 @@
diff -Naurb gcc-4.0.1/gcc/c-incpath.c gcc-4.0.1-new/gcc/c-incpath.c
--- gcc-4.0.1/gcc/c-incpath.c Sun Jan 23 15:05:27 2005
+++ gcc-4.0.1-new/gcc/c-incpath.c Fri Jul 8 11:32:20 2005
@@ -331,13 +331,18 @@
cpp_dir *p;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Convert all backslashes to slashes. The native CRT stat()
- function does not recognize a directory that ends in a backslash
- (unless it is a drive root dir, such "c:\"). Forward slashes,
- trailing or otherwise, cause no problems for stat(). */
- char* c;
- for (c = path; *c; c++)
- if (*c == '\\') *c = '/';
+ /* Remove unnecessary trailing slashes. On some versions of MS
+ Windows, trailing _forward_ slashes cause no problems for stat().
+ On newer versions, stat() does not recognise a directory that ends
+ in a '\\' or '/', unless it is a drive root dir, such as "c:/",
+ where it is obligatory. */
+ int pathlen = strlen (path);
+ char* end = path + pathlen - 1;
+ /* Preserve the lead '/' or lead "c:/". */
+ char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
+
+ for (; end > start && IS_DIR_SEPARATOR (*end); end--)
+ *end = 0;
#endif
p = xmalloc (sizeof (cpp_dir));
diff -Naurb gcc-4.0.1/gcc/version.c gcc-4.0.1-arm/gcc/version.c
--- gcc-4.0.1/gcc/version.c Thu Jul 7 19:41:54 2005
+++ gcc-4.0.1-arm/gcc/version.c Tue Jul 26 22:31:02 2005
@@ -14,4 +14,4 @@
forward us bugs reported to you, if you determine that they are
not bugs in your modifications.) */
-const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
+const char bug_report_url[] = "<URL:http://devkitpro.sourceforge.net/bugs.shtml>";
diff -Naurb gcc-4.0.1/gcc/config/arm/t-arm-elf gcc-4.0.1-new/gcc/config/arm/t-arm-elf
--- gcc-4.0.1/gcc/config/arm/t-arm-elf Wed Sep 1 12:14:21 2004
+++ gcc-4.0.1-new/gcc/config/arm/t-arm-elf Wed Jul 20 23:25:14 2005
@@ -23,8 +23,8 @@
# MULTILIB_DIRNAMES += fpu soft
# MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*
#
-# MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
-# MULTILIB_DIRNAMES += normal interwork
+MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
+MULTILIB_DIRNAMES += normal interwork
#
# MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
# MULTILIB_DIRNAMES += elf under
diff -Naurb gcc-4.0.1/gcc/hwint.h gcc-4.0.1-new/gcc/hwint.h
--- gcc-4.0.1/gcc/hwint.h Wed Nov 24 04:31:57 2004
+++ gcc-4.0.1-new/gcc/hwint.h Thu Jul 21 14:37:06 2005
@@ -80,7 +80,7 @@
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
# endif
#else
-# define HOST_WIDE_INT_PRINT "ll"
+# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
# define HOST_WIDE_INT_PRINT_C "LL"
/* We can assume that 'long long' is at least 64 bits. */
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \

View File

@ -0,0 +1,64 @@
diff -Naurb gcc-4.0.1/gcc/c-incpath.c gcc-4.0.1-new/gcc/c-incpath.c
--- gcc-4.0.1/gcc/c-incpath.c Sun Jan 23 15:05:27 2005
+++ gcc-4.0.1-new/gcc/c-incpath.c Fri Jul 8 11:32:20 2005
@@ -331,13 +331,18 @@
cpp_dir *p;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Convert all backslashes to slashes. The native CRT stat()
- function does not recognize a directory that ends in a backslash
- (unless it is a drive root dir, such "c:\"). Forward slashes,
- trailing or otherwise, cause no problems for stat(). */
- char* c;
- for (c = path; *c; c++)
- if (*c == '\\') *c = '/';
+ /* Remove unnecessary trailing slashes. On some versions of MS
+ Windows, trailing _forward_ slashes cause no problems for stat().
+ On newer versions, stat() does not recognise a directory that ends
+ in a '\\' or '/', unless it is a drive root dir, such as "c:/",
+ where it is obligatory. */
+ int pathlen = strlen (path);
+ char* end = path + pathlen - 1;
+ /* Preserve the lead '/' or lead "c:/". */
+ char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
+
+ for (; end > start && IS_DIR_SEPARATOR (*end); end--)
+ *end = 0;
#endif
p = xmalloc (sizeof (cpp_dir));
diff -Naurb gcc-4.0.1/gcc/version.c gcc-4.0.1-arm/gcc/version.c
--- gcc-4.0.1/gcc/version.c Thu Jul 7 19:41:54 2005
+++ gcc-4.0.1-arm/gcc/version.c Tue Jul 26 22:31:02 2005
@@ -14,4 +14,4 @@
forward us bugs reported to you, if you determine that they are
not bugs in your modifications.) */
-const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
+const char bug_report_url[] = "<URL:http://devkitpro.sourceforge.net/bugs.shtml>";
diff -Naurb gcc-4.0.1/gcc/config/arm/t-arm-elf gcc-4.0.1-new/gcc/config/arm/t-arm-elf
--- gcc-4.0.1/gcc/config/arm/t-arm-elf Wed Sep 1 12:14:21 2004
+++ gcc-4.0.1-new/gcc/config/arm/t-arm-elf Wed Jul 20 23:25:14 2005
@@ -23,8 +23,8 @@
# MULTILIB_DIRNAMES += fpu soft
# MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*
#
-# MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
-# MULTILIB_DIRNAMES += normal interwork
+MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
+MULTILIB_DIRNAMES += normal interwork
#
# MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
# MULTILIB_DIRNAMES += elf under
diff -Naurb gcc-4.0.1/gcc/hwint.h gcc-4.0.1-new/gcc/hwint.h
--- gcc-4.0.1/gcc/hwint.h Wed Nov 24 04:31:57 2004
+++ gcc-4.0.1-new/gcc/hwint.h Thu Jul 21 14:37:06 2005
@@ -80,7 +80,7 @@
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
# endif
#else
-# define HOST_WIDE_INT_PRINT "ll"
+# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
# define HOST_WIDE_INT_PRINT_C "LL"
/* We can assume that 'long long' is at least 64 bits. */
# define HOST_WIDE_INT_PRINT_DOUBLE_HEX \

View File

@ -0,0 +1,126 @@
diff -Naurb gcc-4.1.0/gcc/c-incpath.c gcc-4.1.0-arm/gcc/c-incpath.c
--- gcc-4.1.0/gcc/c-incpath.c Sat Jun 25 03:02:01 2005
+++ gcc-4.1.0-arm/gcc/c-incpath.c Wed Apr 12 16:00:30 2006
@@ -331,13 +331,18 @@
cpp_dir *p;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Convert all backslashes to slashes. The native CRT stat()
- function does not recognize a directory that ends in a backslash
- (unless it is a drive root dir, such "c:\"). Forward slashes,
- trailing or otherwise, cause no problems for stat(). */
- char* c;
- for (c = path; *c; c++)
- if (*c == '\\') *c = '/';
+ /* Remove unnecessary trailing slashes. On some versions of MS
+ Windows, trailing _forward_ slashes cause no problems for stat().
+ On newer versions, stat() does not recognise a directory that ends
+ in a '\\' or '/', unless it is a drive root dir, such as "c:/",
+ where it is obligatory. */
+ int pathlen = strlen (path);
+ char* end = path + pathlen - 1;
+ /* Preserve the lead '/' or lead "c:/". */
+ char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
+
+ for (; end > start && IS_DIR_SEPARATOR (*end); end--)
+ *end = 0;
#endif
p = xmalloc (sizeof (cpp_dir));
diff -Naurb gcc-4.1.0/gcc/gcc.c gcc-4.1.0-arm/gcc/gcc.c
--- gcc-4.1.0/gcc/gcc.c Sat Jan 21 18:29:08 2006
+++ gcc-4.1.0-arm/gcc/gcc.c Fri May 5 10:18:31 2006
@@ -3250,8 +3250,6 @@
gcc_libexec_prefix = make_relative_prefix (argv[0],
standard_bindir_prefix,
standard_libexec_prefix);
- if (gcc_exec_prefix)
- putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
}
else
gcc_libexec_prefix = make_relative_prefix (gcc_exec_prefix,
@@ -6148,10 +6146,10 @@
/* We need to check standard_exec_prefix/just_machine_suffix/specs
for any override of as, ld and libraries. */
- specs_file = alloca (strlen (standard_exec_prefix)
+ specs_file = alloca (strlen (gcc_exec_prefix)
+ strlen (just_machine_suffix) + sizeof ("specs"));
- strcpy (specs_file, standard_exec_prefix);
+ strcpy (specs_file, gcc_exec_prefix);
strcat (specs_file, just_machine_suffix);
strcat (specs_file, "specs");
if (access (specs_file, R_OK) == 0)
diff -Naurb gcc-4.1.0/gcc/prefix.c gcc-4.1.0-arm/gcc/prefix.c
--- gcc-4.1.0/gcc/prefix.c Sat Jun 25 03:02:01 2005
+++ gcc-4.1.0-arm/gcc/prefix.c Fri May 5 10:18:51 2006
@@ -246,13 +246,16 @@
The returned string is always malloc-ed, and the caller is
responsible for freeing it. */
+
+static const char *old_prefix = PREFIX;
+
char *
update_path (const char *path, const char *key)
{
char *result, *p;
- const int len = strlen (std_prefix);
+ const int len = strlen (old_prefix);
- if (! strncmp (path, std_prefix, len)
+ if (! strncmp (path, old_prefix, len)
&& (IS_DIR_SEPARATOR(path[len])
|| path[len] == '\0')
&& key != 0)
@@ -354,4 +357,6 @@
set_std_prefix (const char *prefix, int len)
{
std_prefix = save_string (prefix, len);
+
+ putenv (concat ("GCC_EXEC_PREFIX=", std_prefix, NULL));
}
diff -Naurb gcc-4.1.0/gcc/toplev.c gcc-4.1.0-arm/gcc/toplev.c
--- gcc-4.1.0/gcc/toplev.c Sat Feb 4 22:13:20 2006
+++ gcc-4.1.0-arm/gcc/toplev.c Wed Apr 26 16:49:36 2006
@@ -82,6 +82,7 @@
#include "value-prof.h"
#include "alloc-pool.h"
#include "tree-mudflap.h"
+#include "prefix.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
@@ -1434,6 +1435,10 @@
progname = p;
xmalloc_set_program_name (progname);
+
+ p = getenv("GCC_EXEC_PREFIX");
+ set_std_prefix (p, strlen(p));
+
hex_init ();
diff -Naurb gcc-4.1.0/gcc/version.c gcc-4.1.0-arm/gcc/version.c
--- gcc-4.1.0/gcc/version.c Wed Mar 16 06:04:10 2005
+++ gcc-4.1.0-arm/gcc/version.c Wed Apr 12 16:00:30 2006
@@ -8,7 +8,7 @@
in parentheses. You may also wish to include a number indicating
the revision of your modified compiler. */
-#define VERSUFFIX ""
+#define VERSUFFIX " (devkitARM release 19)"
/* This is the location of the online document giving instructions for
reporting bugs. If you distribute a modified version of GCC,
@@ -17,7 +17,7 @@
forward us bugs reported to you, if you determine that they are
not bugs in your modifications.) */
-const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
+const char bug_report_url[] = "<URL:http://devkitpro.sourceforge.net/bugs.shtml>";
/* The complete version string, assembled from several pieces.
BASEVER, DATESTAMP, and DEVPHASE are defined by the Makefile. */

View File

@ -0,0 +1,126 @@
diff -Naurb gcc-4.1.0/gcc/c-incpath.c gcc-4.1.0-arm/gcc/c-incpath.c
--- gcc-4.1.0/gcc/c-incpath.c Sat Jun 25 03:02:01 2005
+++ gcc-4.1.0-arm/gcc/c-incpath.c Wed Apr 12 16:00:30 2006
@@ -331,13 +331,18 @@
cpp_dir *p;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Convert all backslashes to slashes. The native CRT stat()
- function does not recognize a directory that ends in a backslash
- (unless it is a drive root dir, such "c:\"). Forward slashes,
- trailing or otherwise, cause no problems for stat(). */
- char* c;
- for (c = path; *c; c++)
- if (*c == '\\') *c = '/';
+ /* Remove unnecessary trailing slashes. On some versions of MS
+ Windows, trailing _forward_ slashes cause no problems for stat().
+ On newer versions, stat() does not recognise a directory that ends
+ in a '\\' or '/', unless it is a drive root dir, such as "c:/",
+ where it is obligatory. */
+ int pathlen = strlen (path);
+ char* end = path + pathlen - 1;
+ /* Preserve the lead '/' or lead "c:/". */
+ char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
+
+ for (; end > start && IS_DIR_SEPARATOR (*end); end--)
+ *end = 0;
#endif
p = xmalloc (sizeof (cpp_dir));
diff -Naurb gcc-4.1.0/gcc/gcc.c gcc-4.1.0-arm/gcc/gcc.c
--- gcc-4.1.0/gcc/gcc.c Sat Jan 21 18:29:08 2006
+++ gcc-4.1.0-arm/gcc/gcc.c Fri May 5 10:18:31 2006
@@ -3250,8 +3250,6 @@
gcc_libexec_prefix = make_relative_prefix (argv[0],
standard_bindir_prefix,
standard_libexec_prefix);
- if (gcc_exec_prefix)
- putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
}
else
gcc_libexec_prefix = make_relative_prefix (gcc_exec_prefix,
@@ -6148,10 +6146,10 @@
/* We need to check standard_exec_prefix/just_machine_suffix/specs
for any override of as, ld and libraries. */
- specs_file = alloca (strlen (standard_exec_prefix)
+ specs_file = alloca (strlen (gcc_exec_prefix)
+ strlen (just_machine_suffix) + sizeof ("specs"));
- strcpy (specs_file, standard_exec_prefix);
+ strcpy (specs_file, gcc_exec_prefix);
strcat (specs_file, just_machine_suffix);
strcat (specs_file, "specs");
if (access (specs_file, R_OK) == 0)
diff -Naurb gcc-4.1.0/gcc/prefix.c gcc-4.1.0-arm/gcc/prefix.c
--- gcc-4.1.0/gcc/prefix.c Sat Jun 25 03:02:01 2005
+++ gcc-4.1.0-arm/gcc/prefix.c Fri May 5 10:18:51 2006
@@ -246,13 +246,16 @@
The returned string is always malloc-ed, and the caller is
responsible for freeing it. */
+
+static const char *old_prefix = PREFIX;
+
char *
update_path (const char *path, const char *key)
{
char *result, *p;
- const int len = strlen (std_prefix);
+ const int len = strlen (old_prefix);
- if (! strncmp (path, std_prefix, len)
+ if (! strncmp (path, old_prefix, len)
&& (IS_DIR_SEPARATOR(path[len])
|| path[len] == '\0')
&& key != 0)
@@ -354,4 +357,6 @@
set_std_prefix (const char *prefix, int len)
{
std_prefix = save_string (prefix, len);
+
+ putenv (concat ("GCC_EXEC_PREFIX=", std_prefix, NULL));
}
diff -Naurb gcc-4.1.0/gcc/toplev.c gcc-4.1.0-arm/gcc/toplev.c
--- gcc-4.1.0/gcc/toplev.c Sat Feb 4 22:13:20 2006
+++ gcc-4.1.0-arm/gcc/toplev.c Wed Apr 26 16:49:36 2006
@@ -82,6 +82,7 @@
#include "value-prof.h"
#include "alloc-pool.h"
#include "tree-mudflap.h"
+#include "prefix.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
@@ -1434,6 +1435,10 @@
progname = p;
xmalloc_set_program_name (progname);
+
+ p = getenv("GCC_EXEC_PREFIX");
+ set_std_prefix (p, strlen(p));
+
hex_init ();
diff -Naurb gcc-4.1.0/gcc/version.c gcc-4.1.0-arm/gcc/version.c
--- gcc-4.1.0/gcc/version.c Wed Mar 16 06:04:10 2005
+++ gcc-4.1.0-arm/gcc/version.c Wed Apr 12 16:00:30 2006
@@ -8,7 +8,7 @@
in parentheses. You may also wish to include a number indicating
the revision of your modified compiler. */
-#define VERSUFFIX ""
+#define VERSUFFIX " (devkitARM release 19)"
/* This is the location of the online document giving instructions for
reporting bugs. If you distribute a modified version of GCC,
@@ -17,7 +17,7 @@
forward us bugs reported to you, if you determine that they are
not bugs in your modifications.) */
-const char bug_report_url[] = "<URL:http://gcc.gnu.org/bugs.html>";
+const char bug_report_url[] = "<URL:http://devkitpro.sourceforge.net/bugs.shtml>";
/* The complete version string, assembled from several pieces.
BASEVER, DATESTAMP, and DEVPHASE are defined by the Makefile. */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
#---------------------------------------------------------------------------------
# path to tools - this can be deleted if you set the path in windows
#---------------------------------------------------------------------------------
export PATH := $(DEVKITARM)/bin:$(PATH)
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
PREFIX := arm-eabi-
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AS := $(PREFIX)as
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@echo $(notdir $@)
@rm -f $@
$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.cpp
@echo $(notdir $<)
$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -marm-c $< -o $@
#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -marm -c $< -o $@
#---------------------------------------------------------------------------------
%.itcm.o: %.itcm.cpp
@echo $(notdir $<)
$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -marm-c $< -o $@
#---------------------------------------------------------------------------------
%.itcm.o: %.itcm.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -marm -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.s
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.S
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
bin2s $< | $(AS) $(ARCH) -o $(@)
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef

32
dkarm-eabi/rules/ds_rules Normal file
View File

@ -0,0 +1,32 @@
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITARM)/base_rules
LIBNDS := $(DEVKITPRO)/libnds
#---------------------------------------------------------------------------------
%.ds.gba: %.nds
@dsbuild $<
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.nds: %.arm9
@ndstool -c $@ -9 $<
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.arm9: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.arm7: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@

View File

@ -0,0 +1,23 @@
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITARM)/base_rules
LIBGBA := $(DEVKITPRO)/libgba
#---------------------------------------------------------------------------------
%.gba: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
@gbafix $@
#---------------------------------------------------------------------------------
%_mb.elf:
@echo linking multiboot
@$(LD) -specs=gba_mb.specs $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
%.elf:
@echo linking cartridge
@$(LD) $(LDFLAGS) -specs=gba.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@

View File

@ -0,0 +1,18 @@
-include $(DEVKITARM)/base_rules
LIBMIRKO := $(DEVKITPRO)/libmirko
#---------------------------------------------------------------------------------
%.fxe: %.bin
@b2fxec -a "$(AUTHOR)" -t "$(TITLE)" $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.bin: %.elf
@$(OBJCOPY) -O binary $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking binary
@$(LD) $(LDFLAGS) -specs=gp32.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@

View File

@ -0,0 +1,37 @@
#!/bin/sh
export DEVKITARM=$TOOLPATH/devkitARM
export DEVKITPRO=$TOOLPATH
#---------------------------------------------------------------------------------
# Install and build the gba crt
#---------------------------------------------------------------------------------
cp $(pwd)/dkarm-eabi/crtls/* $DEVKITARM/arm-eabi/lib/
cd $DEVKITARM/arm-eabi/lib/
$MAKE CRT=gba
$MAKE CRT=gp32
$MAKE CRT=er
$MAKE CRT=gp32_gpsdk
$MAKE CRT=ds_arm7
$MAKE CRT=ds_arm9
$MAKE CRT=ds_cart
cd $BUILDSCRIPTDIR
$MAKE -C tools/general
$MAKE -C tools/general install PREFIX=$DEVKITARM/bin
#---------------------------------------------------------------------------------
# copy base rulesets
#---------------------------------------------------------------------------------
cp dkarm-eabi/rules/* $DEVKITARM
cd $LIBNDS_SRCDIR
echo "building libnds ..."
$MAKE install INSTALLDIR=$TOOLPATH
echo "building libgba ..."
cd $BUILDSCRIPTDIR
cd $LIBGBA_SRCDIR
$MAKE install INSTALLDIR=$TOOLPATH

View File

@ -0,0 +1,117 @@
#!/bin/sh
#---------------------------------------------------------------------------------
# Check Parameters
#---------------------------------------------------------------------------------
prefix=$INSTALLDIR/devkitARM
#---------------------------------------------------------------------------------
# build and install binutils
#---------------------------------------------------------------------------------
mkdir -p $target/binutils
cd $target/binutils
../../$BINUTILS_SRCDIR/configure \
--prefix=$prefix --target=$target --disable-nls --disable-shared --disable-debug \
--disable-threads --with-gcc --with-gnu-as --with-gnu-ld \
|| { echo "Error configuring binutils"; exit 1; }
$MAKE || { echo "Error building binutils"; exit 1; }
$MAKE install || { echo "Error installing binutils"; exit 1; }
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# build and install elf2flt
#---------------------------------------------------------------------------------
mkdir -p $target/elf2flt
cd $target/elf2flt
../../elf2flt/configure \
--prefix=$prefix --target=$target \
--with-libbfd=../binutils/bfd/libbfd.a \
--with-libiberty=../binutils/libiberty/libiberty.a \
--with-bfd-include-dir=../binutils/bfd/ \
--with-binutils-include-dir=../../$BINUTILS_SRCDIR/include/ \
|| { echo "Error configuring elf2flt"; exit 1; }
$MAKE || { echo "Error building elf2flt"; exit 1; }
$MAKE install || { echo "Error installing elf2flt"; exit 1; }
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/binutils
rm -fr $BINUTILS_SRCDIR
rm -fr $target/elf2flt
rm -fr elf2flt
#---------------------------------------------------------------------------------
# build and install just the c compiler
#---------------------------------------------------------------------------------
mkdir -p $target/gcc
cd $target/gcc
../../$GCC_SRCDIR/configure \
--enable-languages=c,c++ \
--with-cpu=arm7tdmi\
--enable-interwork --enable-multilib\
--with-gcc --with-gnu-ld --with-gnu-as \
--disable-shared --disable-threads --disable-win32-registry --disable-nls --disable-debug\
--disable-libmudflap --disable-libssp \
--target=$target \
--with-newlib \
--prefix=$prefix\
|| { echo "Error configuring gcc"; exit 1; }
mkdir -p libiberty libcpp fixincludes
$MAKE all-gcc || { echo "Error building gcc"; exit 1; }
$MAKE install-gcc || { echo "Error installing gcc"; exit 1; }
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# build and install newlib
#---------------------------------------------------------------------------------
mkdir -p $target/newlib
cd $target/newlib
mkdir -p etc
$BUILDSCRIPTDIR/$NEWLIB_SRCDIR/configure \
--disable-newlib-supplied-syscalls \
--disable-debug \
--target=$target \
--prefix=$prefix \
|| { echo "Error configuring newlib"; exit 1; }
$MAKE || { echo "Error building newlib"; exit 1; }
$MAKE install || { echo "Error installing newlib"; exit 1; }
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/newlib
rm -fr $NEWLIB_SRCDIR
#---------------------------------------------------------------------------------
# build and install the final compiler
#---------------------------------------------------------------------------------
cd $BUILDSCRIPTDIR
cd $target/gcc
$MAKE || { echo "Error building g++"; exit 1; }
$MAKE install || { echo "Error installing g++"; exit 1; }
cd $BUILDSCRIPTDIR
#---------------------------------------------------------------------------------
# remove temp stuff to conserve disc space
#---------------------------------------------------------------------------------
rm -fr $target/gcc
rm -fr $GCC_SRCDIR

View File

@ -0,0 +1,16 @@
#!/bin/sh
export DEVKITARM=$TOOLPATH/devkitARM
export DEVKITPRO=$TOOLPATH
$MAKE -C tools/gba
$MAKE -C tools/gba install PREFIX=$DEVKITARM/bin
$MAKE -C tools/gp32
$MAKE -C tools/gp32 install PREFIX=$DEVKITARM/bin
$MAKE -C tools/nds/
$MAKE -C tools/nds/ install PREFIX=$DEVKITARM/bin
$MAKE -C tools clean

View File

@ -147,6 +147,7 @@ SECTIONS
*(.dynbss)
*(.gnu.linkonce.b*)
*(COMMON)
*(.bss*)
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} > ram
__bss_end = . ;

View File

@ -1,4 +1,8 @@
-include $(DEVKITARM)/base_rules
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITARM)/base_rules
LIBGBA := $(DEVKITPRO)/libgba

View File

@ -14,7 +14,7 @@ cd $target/binutils
../../$BINUTILS_SRCDIR/configure \
--prefix=$prefix --target=$target --disable-nls --disable-shared --disable-debug \
--disable-threads --with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
--disable-threads --with-gcc --with-gnu-as --with-gnu-ld \
|| { echo "Error configuring binutils"; exit 1; }
$MAKE || { echo "Error building binutils"; exit 1; }
@ -60,7 +60,7 @@ cd $target/gcc
--enable-languages=c,c++ \
--with-cpu=arm7tdmi\
--enable-interwork --enable-multilib\
--with-gcc --with-gnu-ld --with-gnu-as --with-stabs \
--with-gcc --with-gnu-ld --with-gnu-as \
--disable-shared --disable-threads --disable-win32-registry --disable-nls --disable-debug\
--disable-libmudflap --disable-libssp \
--target=$target \