Skip to content

Commit f14127b

Browse files
aykevldeadprogram
authored andcommitted
targets/gba: make linker script cleaner
Make it clearer where the stack is located. Additionally, get the heap to work (the GC needs to have _stack_top defined to work correctly).
1 parent a9b2d8c commit f14127b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

targets/gameboy-advance.ld

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ MEMORY {
77
rom : ORIGIN = 0x08000000, LENGTH = 32M /* flash ROM */
88
}
99

10-
__iwram_top = ORIGIN(iwram) + LENGTH(iwram);;
11-
_stack_size = 3K;
12-
__sp_irq = _stack_top;
13-
__sp_usr = _stack_top - 1K;
10+
__stack_size_irq = 1K;
11+
__stack_size_usr = 2K;
1412

1513
SECTIONS
1614
{
@@ -35,8 +33,10 @@ SECTIONS
3533
.stack (NOLOAD) :
3634
{
3735
. = ALIGN(4);
38-
. += _stack_size;
36+
_stack_top_irq = .;
37+
. += __stack_size_irq;
3938
_stack_top = .;
39+
. += __stack_size_usr;
4040
} >iwram
4141

4242
/* Start address (in flash) of .data, used by startup code. */

targets/gameboy-advance.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ start_vector:
2222

2323
mov r0, #0x12 // Switch to IRQ Mode
2424
msr cpsr, r0
25-
ldr sp, =__sp_irq // Set IRQ stack
25+
ldr sp, =_stack_top_irq // Set IRQ stack
2626
mov r0, #0x1f // Switch to System Mode
2727
msr cpsr, r0
28-
ldr sp, =__sp_usr // Set user stack
28+
ldr sp, =_stack_top // Set user stack
2929

3030
// Jump to user code (switching to Thumb mode)
3131
ldr r3, =main

0 commit comments

Comments
 (0)