Skip to content

Commit

Permalink
Refactor fusee's makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxSH committed May 26, 2018
1 parent ad5be3c commit c9723d7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 65 deletions.
65 changes: 34 additions & 31 deletions fusee/fusee-primary/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)

PHDRS
{
crt0 PT_LOAD;
chainloader PT_LOAD;
main PT_LOAD;
}

/* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY
{
Expand All @@ -19,42 +26,38 @@ SECTIONS
PROVIDE(__heap_end__ = 0);

. = __start__;
. = ALIGN(32);

.crt0 :
{
. = ALIGN(32);
KEEP( *(.text.start) )
KEEP( *(.init) )
. = ALIGN(4);
} >main
. = ALIGN(32);
} >main :crt0

.chainloader_loadable :
{
. = ALIGN(32);
PROVIDE (__chainloader_start__ = .);
PROVIDE (__chainloader_start__ = ABSOLUTE(.));
PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable));
KEEP(*(.chainloader.text.start))
chainloader.o(.text*)
chainloader.o(.rodata*)
chainloader.o(.data*)
. = ALIGN(8);

} >low_iram AT>main
. = ALIGN(32);
} >low_iram AT>main :chainloader

.chainloader_bss :
.chainloader_bss (NOLOAD) :
{
. = ALIGN(8);
PROVIDE (__chainloader_bss_start__ = .);
. = ALIGN(32);
PROVIDE (__chainloader_bss_start__ = ABSOLUTE(.));
chainloader.o(.bss* COMMON)
. = ALIGN(8);
PROVIDE (__chainloader_end__ = .);
} >low_iram AT>main
. = ALIGN(32);
PROVIDE (__chainloader_end__ = ABSOLUTE(.));
} >low_iram :NONE

.text :
{
. = ALIGN(4);

. = ALIGN(32);
/* .text */
*(.text)
*(.text.*)
Expand All @@ -63,12 +66,11 @@ SECTIONS
*(.stub)
*(.gnu.warning)
*(.gnu.linkonce.t*)
. = ALIGN(4);

/* .fini */
KEEP( *(.fini) )
. = ALIGN(4);
} >main
. = ALIGN(8);
} >main :main

.rodata :
{
Expand All @@ -78,10 +80,10 @@ SECTIONS
*all.rodata*(*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4);
. = ALIGN(8);
} >main

.preinit_array ALIGN(4) :
.preinit_array :
{
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
Expand Down Expand Up @@ -110,6 +112,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main

.dtors ALIGN(4) :
Expand All @@ -118,33 +121,33 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main
__exidx_start = .;
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = ABSOLUTE(.);} >main
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = ABSOLUTE(.);} >main

.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
. = ALIGN(32);
} >main

.bss :
.bss (NOLOAD) :
{
__bss_start__ = ALIGN(32);
. = ALIGN(32);
PROVIDE (__bss_start__ = ABSOLUTE(.));
*(.dynbss)
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(8);
__bss_end__ = .;
} >main
. = ALIGN(32);
PROVIDE (__bss_end__ = ABSOLUTE(.));
} >main :NONE
__end__ = ABSOLUTE(.) ;

/* ==================
Expand Down
2 changes: 1 addition & 1 deletion fusee/fusee-primary/src/exception_handlers_asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

.section .text.exception_handlers_asm, "ax", %progbits
.arm
.align 4
.align 5

_exception_handler_common:
mrs r2, spsr
Expand Down
66 changes: 34 additions & 32 deletions fusee/fusee-secondary/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)

PHDRS
{
crt0 PT_LOAD;
chainloader PT_LOAD;
main PT_LOAD;
}

/* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY
{
NULL : ORIGIN = 0x00000000, LENGTH = 0x1000
main : ORIGIN = 0xF0000000, LENGTH = 0x10000000
low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000
}
Expand All @@ -19,42 +25,38 @@ SECTIONS
PROVIDE(__heap_end__ = 0xF0000000);

. = __start__;
. = ALIGN(32);

.crt0 :
{
. = ALIGN(32);
KEEP( *(.text.start) )
KEEP( *(.init) )
. = ALIGN(4);
} >main
. = ALIGN(32);
} >main :crt0

.chainloader_loadable :
{
. = ALIGN(32);
PROVIDE (__chainloader_start__ = .);
PROVIDE (__chainloader_start__ = ABSOLUTE(.));
PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable));
KEEP(*(.chainloader.text.start))
chainloader.o(.text*)
chainloader.o(.rodata*)
chainloader.o(.data*)
. = ALIGN(8);

} >low_iram AT>main
. = ALIGN(32);
} >low_iram AT>main :chainloader

.chainloader_bss :
.chainloader_bss (NOLOAD) :
{
. = ALIGN(8);
PROVIDE (__chainloader_bss_start__ = .);
. = ALIGN(32);
PROVIDE (__chainloader_bss_start__ = ABSOLUTE(.));
chainloader.o(.bss* COMMON)
. = ALIGN(8);
PROVIDE (__chainloader_end__ = .);
} >low_iram AT>main
. = ALIGN(32);
PROVIDE (__chainloader_end__ = ABSOLUTE(.));
} >low_iram :NONE

.text :
{
. = ALIGN(4);

. = ALIGN(32);
/* .text */
*(.text)
*(.text.*)
Expand All @@ -63,12 +65,11 @@ SECTIONS
*(.stub)
*(.gnu.warning)
*(.gnu.linkonce.t*)
. = ALIGN(4);

/* .fini */
KEEP( *(.fini) )
. = ALIGN(4);
} >main
. = ALIGN(8);
} >main :main

.rodata :
{
Expand All @@ -78,10 +79,10 @@ SECTIONS
*all.rodata*(*)
*(.gnu.linkonce.r*)
SORT(CONSTRUCTORS)
. = ALIGN(4);
. = ALIGN(8);
} >main

.preinit_array ALIGN(4) :
.preinit_array :
{
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
Expand Down Expand Up @@ -110,6 +111,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main

.dtors ALIGN(4) :
Expand All @@ -118,33 +120,33 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main
__exidx_start = .;
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = ABSOLUTE(.);} >main
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = ABSOLUTE(.);} >main

.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
. = ALIGN(4);
. = ALIGN(32);
} >main

.bss :
.bss (NOLOAD) :
{
__bss_start__ = ALIGN(32);
. = ALIGN(32);
PROVIDE (__bss_start__ = ABSOLUTE(.));
*(.dynbss)
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(8);
__bss_end__ = .;
} >main
. = ALIGN(32);
PROVIDE (__bss_end__ = ABSOLUTE(.));
} >main :NONE
__end__ = ABSOLUTE(.) ;

/* ==================
Expand Down
2 changes: 1 addition & 1 deletion fusee/fusee-secondary/src/exception_handlers_asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

.section .text.exception_handlers_asm, "ax", %progbits
.arm
.align 4
.align 5

_exception_handler_common:
mrs r2, spsr
Expand Down

0 comments on commit c9723d7

Please sign in to comment.