1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-09-19 21:43:29 +01:00

Refactor fusee's makefile

This commit is contained in:
TuxSH 2018-05-27 00:59:02 +02:00
parent ad5be3cae5
commit c9723d7b68
4 changed files with 70 additions and 65 deletions

View file

@ -2,6 +2,13 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
ENTRY(_start) 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 */ /* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY MEMORY
{ {
@ -19,42 +26,38 @@ SECTIONS
PROVIDE(__heap_end__ = 0); PROVIDE(__heap_end__ = 0);
. = __start__; . = __start__;
. = ALIGN(32);
.crt0 : .crt0 :
{ {
. = ALIGN(32);
KEEP( *(.text.start) ) KEEP( *(.text.start) )
KEEP( *(.init) ) KEEP( *(.init) )
. = ALIGN(4); . = ALIGN(32);
} >main } >main :crt0
.chainloader_loadable : .chainloader_loadable :
{ {
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__chainloader_start__ = .); PROVIDE (__chainloader_start__ = ABSOLUTE(.));
PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable)); PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable));
KEEP(*(.chainloader.text.start)) KEEP(*(.chainloader.text.start))
chainloader.o(.text*) chainloader.o(.text*)
chainloader.o(.rodata*) chainloader.o(.rodata*)
chainloader.o(.data*) chainloader.o(.data*)
. = ALIGN(8); . = ALIGN(32);
} >low_iram AT>main :chainloader
} >low_iram AT>main .chainloader_bss (NOLOAD) :
.chainloader_bss :
{ {
. = ALIGN(8); . = ALIGN(32);
PROVIDE (__chainloader_bss_start__ = .); PROVIDE (__chainloader_bss_start__ = ABSOLUTE(.));
chainloader.o(.bss* COMMON) chainloader.o(.bss* COMMON)
. = ALIGN(8); . = ALIGN(32);
PROVIDE (__chainloader_end__ = .); PROVIDE (__chainloader_end__ = ABSOLUTE(.));
} >low_iram AT>main } >low_iram :NONE
.text : .text :
{ {
. = ALIGN(4); . = ALIGN(32);
/* .text */ /* .text */
*(.text) *(.text)
*(.text.*) *(.text.*)
@ -63,12 +66,11 @@ SECTIONS
*(.stub) *(.stub)
*(.gnu.warning) *(.gnu.warning)
*(.gnu.linkonce.t*) *(.gnu.linkonce.t*)
. = ALIGN(4);
/* .fini */ /* .fini */
KEEP( *(.fini) ) KEEP( *(.fini) )
. = ALIGN(4); . = ALIGN(8);
} >main } >main :main
.rodata : .rodata :
{ {
@ -78,10 +80,10 @@ SECTIONS
*all.rodata*(*) *all.rodata*(*)
*(.gnu.linkonce.r*) *(.gnu.linkonce.r*)
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
. = ALIGN(4); . = ALIGN(8);
} >main } >main
.preinit_array ALIGN(4) : .preinit_array :
{ {
PROVIDE (__preinit_array_start = .); PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(.preinit_array))
@ -110,6 +112,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*))) KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.dtors ALIGN(4) : .dtors ALIGN(4) :
@ -118,12 +121,11 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = ABSOLUTE(.);} >main
__exidx_start = .; ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = ABSOLUTE(.);} >main
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.data : .data :
{ {
@ -131,20 +133,21 @@ SECTIONS
*(.data.*) *(.data.*)
*(.gnu.linkonce.d*) *(.gnu.linkonce.d*)
CONSTRUCTORS CONSTRUCTORS
. = ALIGN(4); . = ALIGN(32);
} >main } >main
.bss : .bss (NOLOAD) :
{ {
__bss_start__ = ALIGN(32); . = ALIGN(32);
PROVIDE (__bss_start__ = ABSOLUTE(.));
*(.dynbss) *(.dynbss)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(.gnu.linkonce.b*) *(.gnu.linkonce.b*)
*(COMMON) *(COMMON)
. = ALIGN(8); . = ALIGN(32);
__bss_end__ = .; PROVIDE (__bss_end__ = ABSOLUTE(.));
} >main } >main :NONE
__end__ = ABSOLUTE(.) ; __end__ = ABSOLUTE(.) ;
/* ================== /* ==================

View file

@ -16,7 +16,7 @@
.section .text.exception_handlers_asm, "ax", %progbits .section .text.exception_handlers_asm, "ax", %progbits
.arm .arm
.align 4 .align 5
_exception_handler_common: _exception_handler_common:
mrs r2, spsr mrs r2, spsr

View file

@ -2,10 +2,16 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
ENTRY(_start) 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 */ /* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */
MEMORY MEMORY
{ {
NULL : ORIGIN = 0x00000000, LENGTH = 0x1000
main : ORIGIN = 0xF0000000, LENGTH = 0x10000000 main : ORIGIN = 0xF0000000, LENGTH = 0x10000000
low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000 low_iram : ORIGIN = 0x40003000, LENGTH = 0x8000
} }
@ -19,42 +25,38 @@ SECTIONS
PROVIDE(__heap_end__ = 0xF0000000); PROVIDE(__heap_end__ = 0xF0000000);
. = __start__; . = __start__;
. = ALIGN(32);
.crt0 : .crt0 :
{ {
. = ALIGN(32);
KEEP( *(.text.start) ) KEEP( *(.text.start) )
KEEP( *(.init) ) KEEP( *(.init) )
. = ALIGN(4); . = ALIGN(32);
} >main } >main :crt0
.chainloader_loadable : .chainloader_loadable :
{ {
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__chainloader_start__ = .); PROVIDE (__chainloader_start__ = ABSOLUTE(.));
PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable)); PROVIDE (__chainloader_lma__ = LOADADDR(.chainloader_loadable));
KEEP(*(.chainloader.text.start)) KEEP(*(.chainloader.text.start))
chainloader.o(.text*) chainloader.o(.text*)
chainloader.o(.rodata*) chainloader.o(.rodata*)
chainloader.o(.data*) chainloader.o(.data*)
. = ALIGN(8); . = ALIGN(32);
} >low_iram AT>main :chainloader
} >low_iram AT>main .chainloader_bss (NOLOAD) :
.chainloader_bss :
{ {
. = ALIGN(8); . = ALIGN(32);
PROVIDE (__chainloader_bss_start__ = .); PROVIDE (__chainloader_bss_start__ = ABSOLUTE(.));
chainloader.o(.bss* COMMON) chainloader.o(.bss* COMMON)
. = ALIGN(8); . = ALIGN(32);
PROVIDE (__chainloader_end__ = .); PROVIDE (__chainloader_end__ = ABSOLUTE(.));
} >low_iram AT>main } >low_iram :NONE
.text : .text :
{ {
. = ALIGN(4); . = ALIGN(32);
/* .text */ /* .text */
*(.text) *(.text)
*(.text.*) *(.text.*)
@ -63,12 +65,11 @@ SECTIONS
*(.stub) *(.stub)
*(.gnu.warning) *(.gnu.warning)
*(.gnu.linkonce.t*) *(.gnu.linkonce.t*)
. = ALIGN(4);
/* .fini */ /* .fini */
KEEP( *(.fini) ) KEEP( *(.fini) )
. = ALIGN(4); . = ALIGN(8);
} >main } >main :main
.rodata : .rodata :
{ {
@ -78,10 +79,10 @@ SECTIONS
*all.rodata*(*) *all.rodata*(*)
*(.gnu.linkonce.r*) *(.gnu.linkonce.r*)
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
. = ALIGN(4); . = ALIGN(8);
} >main } >main
.preinit_array ALIGN(4) : .preinit_array :
{ {
PROVIDE (__preinit_array_start = .); PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array)) KEEP (*(.preinit_array))
@ -110,6 +111,7 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*))) KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors)) KEEP (*(.ctors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.dtors ALIGN(4) : .dtors ALIGN(4) :
@ -118,12 +120,11 @@ SECTIONS
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*))) KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors)) KEEP (*(.dtors))
. = ALIGN(4); /* REQUIRED. LD is flaky without it. */
} >main } >main
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >main .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) __exidx_start = ABSOLUTE(.);} >main
__exidx_start = .; ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = ABSOLUTE(.);} >main
ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >main
__exidx_end = .;
.data : .data :
{ {
@ -131,20 +132,21 @@ SECTIONS
*(.data.*) *(.data.*)
*(.gnu.linkonce.d*) *(.gnu.linkonce.d*)
CONSTRUCTORS CONSTRUCTORS
. = ALIGN(4); . = ALIGN(32);
} >main } >main
.bss : .bss (NOLOAD) :
{ {
__bss_start__ = ALIGN(32); . = ALIGN(32);
PROVIDE (__bss_start__ = ABSOLUTE(.));
*(.dynbss) *(.dynbss)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(.gnu.linkonce.b*) *(.gnu.linkonce.b*)
*(COMMON) *(COMMON)
. = ALIGN(8); . = ALIGN(32);
__bss_end__ = .; PROVIDE (__bss_end__ = ABSOLUTE(.));
} >main } >main :NONE
__end__ = ABSOLUTE(.) ; __end__ = ABSOLUTE(.) ;
/* ================== /* ==================

View file

@ -16,7 +16,7 @@
.section .text.exception_handlers_asm, "ax", %progbits .section .text.exception_handlers_asm, "ax", %progbits
.arm .arm
.align 4 .align 5
_exception_handler_common: _exception_handler_common:
mrs r2, spsr mrs r2, spsr