Code sub-loading working.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15377 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2022-01-18 17:22:54 +00:00
parent d0a8340472
commit 916876b01f
3 changed files with 10 additions and 9 deletions

View File

@ -107,11 +107,11 @@ __sandbox: .long 0xFE9154C0
.bss
.align 2
.global __sb_parameters
.global __sb_parameters
__sb_parameters:
.ds.l 1
.ds.l 1
.global environ /* Required by newlib.*/
.global environ /* Required by newlib.*/
environ:
.ds.l 1
.ds.l 1
@ -227,7 +227,7 @@ finiloop:
endfiniloop:
#endif /* CRT0_CALL_DESTRUCTORS == TRUE */
ldr r1, =__sandbox
ldr r2, [r1], #16 /* Predefined exit vector.*/
ldr r2, [r1, #16] /* Predefined exit vector.*/
bx r2
#endif /* !defined(__DOXYGEN__) */

View File

@ -52,14 +52,14 @@ __callelf_data:
.global __callelf
__callelf:
ldr r4, =__callelf_data
str sp, [r4], #0
str lr, [r4], #4
str sp, [r4, #0]
str lr, [r4, #4]
/* Setting up the call stack for the loaded module.*/
ldr r5, [r0], #20 /* Placed by runelf(). */
ldr r5, [r0, #20] /* Placed by runelf(). */
mov sp, r5
push {r1, r2, r3, r5} /* argc, argv, envp, top. */
ldr r6, [r0], #16
ldr r6, [r0, #12]
bx r6 /* Jumping to entry point. */
/* Call elf return code.*/
@ -68,9 +68,9 @@ __callelf:
.global __returnelf
__returnelf:
ldr r4, =__callelf_data
ldmdb r4, {r5, lr}
ldmia r4, {r5, r6}
mov sp, r5
bx lr
bx r6
#endif /* !defined(__DOXYGEN__) */

View File

@ -56,5 +56,6 @@ int runelf(const char *fname, int argc, char *argv[], char *envp[]) {
/* Setting up the exit vector for the loaded elf file.*/
sbhp->hdr_exit = (uint32_t)__returnelf;
sbhp->user[0] = (uint32_t)bufend;
return __callelf(sbhp, argc, argv, envp);
}