]> granicus.if.org Git - musl/commitdiff
fix code path where child function returns in arm __clone built as thumb
authorRich Felker <dalias@aerifal.cx>
Wed, 11 Sep 2019 17:13:57 +0000 (13:13 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 11 Sep 2019 17:13:57 +0000 (13:13 -0400)
mov lr,pc is not a valid way to save the return address in thumb mode
since it omits the thumb bit. use a chain of bl and bx to emulate blx.
this could be avoided by converting to a .S file with preprocessor
conditions to use blx if available, but the time cost here is
dominated by the syscall anyway.

while making this change, also remove the remnants of support for
pre-bx ISA levels. commit 9f290a49bf9ee247d540d3c83875288a7991699c
removed the hack from the parent code paths, but left the unnecessary
code in the child. keeping it would require rewriting two code paths
rather than one, and is useless for reasons described in that commit.

src/thread/arm/clone.s

index e16b13260e60c9699aa084b1c98471b919d00e8d..bb0965dafe8298e652a5291dd443893153c748af 100644 (file)
@@ -20,13 +20,9 @@ __clone:
        bx lr
 
 1:     mov r0,r6
-       tst r5,#1
-       bne 1f
-       mov lr,pc
-       mov pc,r5
+       bl 3f
 2:     mov r7,#1
        svc 0
-
-1:     mov lr,pc
-       bx r5
        b 2b
+
+3:     bx r5