commit d376a690e119fd335da9ce307531ccdb29cecb01
parent aa67863a9cea46760e13bed997af3455b63be28f
Author: Matsuda Kenji <info@mtkn.jp>
Date: Thu, 14 Mar 2024 08:43:56 +0900
hopefully understand how to access variables defined in the linker script
Diffstat:
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/ex3/main.c b/ex3/main.c
@@ -8,8 +8,8 @@ void *get_sp(void);
void wfi(void);
void *memcpy(void *s1, void *s2, long n);
-extern void proc0_start, proc0_size;
-extern void proc1_start, proc1_size;
+extern char proc0_start, proc0_size;
+extern char proc1_start, proc1_size;
extern char msg0;
extern char msg1;
@@ -40,21 +40,18 @@ main(void) {
puts("main");
puts("main2");
- printh(&proc0_start);
- printh(&proc0_size);
- printh((void*)0x10002000);
- //memcpy((void *)0x20000000, (void *)&proc0_start, (long) &proc0_size);
+ memcpy((void *)0x20000000, &proc0_start, (long) &proc0_size);
puts("main2.5");
- //memcpy((void *)0x20000100, (void *)&proc1_start, (long) &proc1_size);
+ memcpy((void *)0x20000100, &proc1_start, (long) &proc1_size);
puts("main3");
p0.r[13] = (void *) 0x20000100; // sp
- p0.r[14] = (void *) 0xdeadbeef; // lr
+ p0.r[14] = (void *) main; // lr
p0.r[15] = (void *) 0x20000000; // pc
puts("main4");
p1.r[13] = (void *) 0x20000200; // sp
- p1.r[14] = (void *) 0xdeadbeef; // lr
+ p1.r[14] = (void *) main; // lr
p1.r[15] = (void *) 0x20000100; // pc
puts("main5");
diff --git a/ex3/memmap.ld b/ex3/memmap.ld
@@ -21,6 +21,7 @@ SECTIONS
} > SRAM4 AT > FLASH
.rodata : ALIGN(4) {
*(.rodata)
+ *(.got*)
kernel_end = .;
} > SRAM4 AT > FLASH
prog_start = LOADADDR(.text);
@@ -35,5 +36,4 @@ SECTIONS
} > SRAM AT > FLASH
proc1_start = LOADADDR(.proc1);
proc1_size = SIZEOF(.proc1);
-
}