From e6b7dc1dc57bb13e901646c167ed8b706f34a05e Mon Sep 17 00:00:00 2001 From: TuxSH Date: Wed, 23 May 2018 21:20:16 +0200 Subject: [PATCH] Add top-level Makefile + @fincs 's linker script fixes --- Makefile | 29 +++++++++++++++++++++++++++++ arm9/linker.ld | 37 +++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0af9e28 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),) +$(error "Please install firmtool v1.1 or greater") +endif + +NAME := $(notdir $(CURDIR)) +REVISION := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/') + +SUBFOLDERS := sysmodules arm11 arm9 k11_extension + +.PHONY: all release clean $(SUBFOLDERS) + +all: boot.firm + +release: $(NAME)$(REVISION).zip + +clean: + @$(foreach dir, $(SUBFOLDERS), $(MAKE) -C $(dir) clean &&) true + @rm -rf *.firm *.zip + +$(NAME)$(REVISION).zip: boot.firm exception_dump_parser + @zip -r $@ $^ -x "*.DS_Store*" "*__MACOSX*" + +boot.firm: $(SUBFOLDERS) + @firmtool build $@ -D sysmodules/sysmodules.bin arm11/arm11.elf arm9/arm9.elf k11_extension/k11_extension.elf \ + -A 0x18180000 0x18000000 -C XDMA XDMA NDMA XDMA + @echo built... $(notdir $@) + +$(SUBFOLDERS): + @$(MAKE) -C $@ all diff --git a/arm9/linker.ld b/arm9/linker.ld index 821b27d..a4b9e9b 100644 --- a/arm9/linker.ld +++ b/arm9/linker.ld @@ -2,6 +2,13 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) +PHDRS +{ + crt0 PT_LOAD; + itcm PT_LOAD; + main PT_LOAD; +} + /* Mostly copied from https://github.com/devkitPro/buildscripts/blob/master/dkarm-eabi/crtls/3dsx.ld */ MEMORY { @@ -20,19 +27,16 @@ SECTIONS PROVIDE(__itcm_stack_bottom__ = 0x01FFA800); . = __start__; - . = ALIGN(32); .crt0 : { - . = ALIGN(32); KEEP( *(.text.start) ) KEEP( *(.init) ) - . = ALIGN(4); - } >main + . = ALIGN(32); + } >main :crt0 .itcm_loadable : { - . = ALIGN(32); PROVIDE (__itcm_start__ = ABSOLUTE(.)); PROVIDE (__itcm_lma__ = LOADADDR(.itcm_loadable)); @@ -54,25 +58,22 @@ SECTIONS i2c.o(.data*) arm9_exception_handlers.o(.data*) - . = ALIGN(8); - } >itcm AT>main - - .itcm_bss : - { - . = ALIGN(8); + . = ALIGN(32); PROVIDE (__itcm_bss_start__ = ABSOLUTE(.)); + } >itcm AT>main :itcm + + .itcm_bss __itcm_bss_start__ (NOLOAD) : + { *(.arm9_exception_handlers.bss*) chainloader.o(.bss* COMMON) i2c.o(.bss* COMMON) arm9_exception_handlers.o(.bss* COMMON) . = ALIGN(8); - PROVIDE (__itcm_end__ = ABSOLUTE(.)); - } >itcm AT>main + PROVIDE (__itcm_end__ = .); + } >itcm :NONE .text : { - . = ALIGN(4); - /* .text */ *(.text) *(.text.*) @@ -86,7 +87,7 @@ SECTIONS /* .fini */ KEEP( *(.fini) ) . = ALIGN(4); - } >main + } >main :main .rodata : { @@ -153,7 +154,7 @@ SECTIONS . = ALIGN(4); } >main - .bss : + .bss (NOLOAD) : { . = ALIGN(32); PROVIDE (__bss_start__ = ABSOLUTE(.)); @@ -164,7 +165,7 @@ SECTIONS *(COMMON) . = ALIGN(8); PROVIDE (__bss_end__ = ABSOLUTE(.)); - } >main + } >main :NONE __end__ = ABSOLUTE(.) ; /* ==================