From b1b81c87f28baa43023ee024358999ce12d170bf Mon Sep 17 00:00:00 2001 From: TuxSH Date: Thu, 23 Feb 2017 19:30:09 +0100 Subject: [PATCH] Fix linker scripts --- exceptions/arm11/linker.ld | 11 ++++++----- exceptions/arm9/linker.ld | 11 ++++++----- linker.ld | 14 +++++++++----- loader/linker.ld | 11 ++++++----- source/start.s | 8 +++++++- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/exceptions/arm11/linker.ld b/exceptions/arm11/linker.ld index fbaa849..9e7ecd1 100644 --- a/exceptions/arm11/linker.ld +++ b/exceptions/arm11/linker.ld @@ -1,11 +1,12 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + ENTRY(_start) SECTIONS { . = 0; - .text.start : { *(.text.start) } - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss COMMON) } - .rodata : { *(.rodata) } + .text : ALIGN(4) { *(.text.start) *(.text*)} + .rodata : ALIGN(4) { *(.rodata*) } + .data : ALIGN(4) { *(.data*) *(.bss* COMMON)} . = ALIGN(4); } diff --git a/exceptions/arm9/linker.ld b/exceptions/arm9/linker.ld index fc25c15..fa0936c 100644 --- a/exceptions/arm9/linker.ld +++ b/exceptions/arm9/linker.ld @@ -1,11 +1,12 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + ENTRY(_start) SECTIONS { . = 0x01FF7FE0; - .text.start : { *(.text.start) } - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss COMMON) } - .rodata : { *(.rodata) } + .text : ALIGN(4) { *(.text.start) *(.text*)} + .rodata : ALIGN(4) { *(.rodata*) } + .data : ALIGN(4) { *(.data*) *(.bss* COMMON)} . = ALIGN(4); } diff --git a/linker.ld b/linker.ld index d57403d..26789a9 100644 --- a/linker.ld +++ b/linker.ld @@ -1,11 +1,15 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + ENTRY(_start) SECTIONS { . = 0x23F00000; - .text.start : { *(.text.start) } - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss COMMON) } - .rodata : { *(.rodata) } + + .text : ALIGN(4) { *(.text.start) *(.text*) } + .rodata : ALIGN(4) { *(.rodata*) } + .data : ALIGN(4) { *(.data*) } + .bss : ALIGN(4) { __bss_start = .; *(.bss* COMMON); __bss_end = .;} + . = ALIGN(4); } diff --git a/loader/linker.ld b/loader/linker.ld index 2bb7325..8186950 100644 --- a/loader/linker.ld +++ b/loader/linker.ld @@ -1,11 +1,12 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + ENTRY(_start) SECTIONS { . = 0x24FFFE00; - .text.start : { *(.text.start) } - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss COMMON) } - .rodata : { *(.rodata) } + .text : ALIGN(4) { *(.text.start) *(.text*)} + .rodata : ALIGN(4) { *(.rodata*) } + .data : ALIGN(4) { *(.data*) *(.bss* COMMON)} . = ALIGN(4); } diff --git a/source/start.s b/source/start.s index b7765cb..7c6181e 100644 --- a/source/start.s +++ b/source/start.s @@ -58,7 +58,7 @@ start: @ Set MPU permissions and cache settings ldr r0, =0xFFFF001D @ ffff0000 32k | bootrom (unprotected part) ldr r1, =0x01FF801D @ 01ff8000 32k | itcm - ldr r2, =0x08000029 @ 08000000 2M | arm9 mem (O3DS / N3DS) + ldr r2, =0x08000029 @ 08000000 2M | arm9 mem (O3DS / N3DS) ldr r3, =0x10000029 @ 10000000 2M | io mem (ARM9 / first 2MB) ldr r4, =0x20000037 @ 20000000 256M | fcram (O3DS / N3DS) ldr r5, =0x1FF00027 @ 1FF00000 1M | dsp / axi wram @@ -91,4 +91,10 @@ start: mov r1, #0x340 str r1, [r0] + ldr r0, =__bss_start + mov r1, #0 + ldr r2, =__bss_end + sub r2, r0 + bl memset32 + b main