diff mbox

[2/3] Fixed clone() for Cortex-M3

Message ID 1414832344.11706.8.camel@mehome
State New
Headers show

Commit Message

sposelenov@emcraft.com Nov. 1, 2014, 8:59 a.m. UTC
commit 5c6eec82dd4ef1962b92d5d6531f14b6d7a6a30a
Author: Sergei Poselenov <sposelenov@emcraft.com>
Date:   Sun Oct 26 14:53:32 2014 +0400

    Fixed clone() for Cortex-M3.
    
    Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>

Comments

Bernhard Reutner-Fischer Nov. 13, 2014, 6:52 p.m. UTC | #1
On 1 November 2014 09:59, Sergei Poselenov <sposelenov@emcraft.com> wrote:
> commit 5c6eec82dd4ef1962b92d5d6531f14b6d7a6a30a
> Author: Sergei Poselenov <sposelenov@emcraft.com>
> Date:   Sun Oct 26 14:53:32 2014 +0400
>
>     Fixed clone() for Cortex-M3.

Can you please elaborate?

thanks,
>
>     Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
>
> diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S
> index fdc05b8..6c89a10 100644
> --- a/libc/sysdeps/linux/arm/clone.S
> +++ b/libc/sysdeps/linux/arm/clone.S
> @@ -104,26 +104,24 @@ __clone:
>         @ get flags
>         mov     r0, r2
>         @ new sp is already in r1
> -       @ load remaining arguments off the stack
> -       stmfd   sp!, {r4}
> -       ldr     r2, [sp, #4]
> -       ldr     r3, [sp, #8]
> -       ldr     r4, [sp, #12]
>         DO_CALL (clone)
>         movs    a1, a1
>         blt     __error
> -       ldmnefd sp!, {r4}
>         IT(t, ne)
>  #if defined(__USE_BX__)
>         bxne    lr
>  #else
>         movne   pc, lr
>  #endif
> -
>         @ pick the function arg and call address off the stack and execute
>         ldr     r0, [sp, #4]
> -       mov     lr, pc
> -       ldr     pc, [sp]
> +#if defined(__USE_BX__)
> +       ldr     r1, [sp]
> +       blx     r1
> +#else
> +       mov     lr, pc
> +       ldr     pc, [sp]
> +#endif
>
>         @ and we are done, passing the return value through r0
>         b       HIDDEN_JUMPTARGET(_exit)
>
>
Bernhard Reutner-Fischer Nov. 13, 2014, 7:43 p.m. UTC | #2
On 13 November 2014 19:52, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 1 November 2014 09:59, Sergei Poselenov <sposelenov@emcraft.com> wrote:
>> commit 5c6eec82dd4ef1962b92d5d6531f14b6d7a6a30a
>> Author: Sergei Poselenov <sposelenov@emcraft.com>
>> Date:   Sun Oct 26 14:53:32 2014 +0400
>>
>>     Fixed clone() for Cortex-M3.
>
> Can you please elaborate?

Essentially it would be good if somebody using ARM would dig through rth's
recent-ish http://comments.gmane.org/gmane.comp.lib.glibc.ports/2720 and
pick some of the thumb improvement bits.

thanks,
diff mbox

Patch

diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S
index fdc05b8..6c89a10 100644
--- a/libc/sysdeps/linux/arm/clone.S
+++ b/libc/sysdeps/linux/arm/clone.S
@@ -104,26 +104,24 @@  __clone:
 	@ get flags
 	mov	r0, r2
 	@ new sp is already in r1
-	@ load remaining arguments off the stack
-	stmfd	sp!, {r4}
-	ldr	r2, [sp, #4]
-	ldr	r3, [sp, #8]
-	ldr	r4, [sp, #12]
 	DO_CALL (clone)
 	movs	a1, a1
 	blt	__error
-	ldmnefd	sp!, {r4}
 	IT(t, ne)
 #if defined(__USE_BX__)
 	bxne	lr
 #else
 	movne	pc, lr
 #endif
-
 	@ pick the function arg and call address off the stack and execute
 	ldr	r0, [sp, #4]
-	mov	lr, pc
-	ldr 	pc, [sp]
+#if defined(__USE_BX__)
+	ldr 	r1, [sp]
+	blx	r1
+#else
+	mov     lr, pc
+	ldr     pc, [sp]
+#endif
 
 	@ and we are done, passing the return value through r0
 	b	HIDDEN_JUMPTARGET(_exit)