From b0bd6a13ec8c90194990e309f08a983da7abfe2a Mon Sep 17 00:00:00 2001 From: tom_at_work <tom_at_work@idefix.freepascal.org> Date: Sun, 27 Feb 2011 17:22:29 +0000 Subject: [PATCH] Fixed argc/argv/envp for arm/linux shared libraries. They are by default in registers a1/a2/a3 as per ABI: the first arguments when calling a method (in this case the FPC_SHARED_LIB_START) are passed via registers, not on the stack. git-svn-id: trunk@17033 - --- rtl/linux/arm/dllprt0.as | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/rtl/linux/arm/dllprt0.as b/rtl/linux/arm/dllprt0.as index 269d691c04..0e7b7fc661 100644 --- a/rtl/linux/arm/dllprt0.as +++ b/rtl/linux/arm/dllprt0.as @@ -9,32 +9,25 @@ FPC_SHARED_LIB_START: mov ip, sp push {fp, ip, lr, pc} sub fp, ip, #4 - sub sp, sp, #40 - /* load argc */ - mov a1, ip - - /* load and save a copy of argc */ - ldr a2, [a1] + /* a1 contains argc, a2 contains argv and a3 contains envp */ ldr ip, =operatingsystem_parameter_argc - str a2, [ip] - - /* calc argv and store */ - add a1, a1, #4 - ldr ip, =operatingsystem_parameter_argv str a1, [ip] - /* calc envp and store */ - add a2, a2, #1 - add a2, a1, a2, lsl #2 + ldr ip, =operatingsystem_parameter_argv + str a2, [ip] ldr ip, =operatingsystem_parameter_envp - str a2, [ip] + str a3, [ip] /* save initial stackpointer */ ldr ip, =__stklen str sp, [ip] + ldr ip, =TC_SYSTEM_ISLIBRARY + mov a1, #1 + str a1, [ip] + /* call main and exit normally */ bl PASCALMAIN ldmdb fp, {fp, sp, pc}