From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: cortex-m support?
Date: Fri, 9 Dec 2016 01:33:27 -0500 [thread overview]
Message-ID: <20161209063327.GR1555@brightrain.aerifal.cx> (raw)
In-Reply-To: <20161208211116.GO1555@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 1448 bytes --]
On Thu, Dec 08, 2016 at 04:11:16PM -0500, Rich Felker wrote:
> On Tue, Dec 06, 2016 at 11:52:29PM -0600, Rob Landley wrote:
> > Added support for the Cortex-M.
> > ------------------------------------------------------------------------
> > Index: src/internal/arm/syscall.s
> > ===================================================================
> > --- src/internal/arm/syscall.s (revision 4919)
> > +++ src/internal/arm/syscall.s (revision 4920)
> > @@ -11,5 +11,6 @@
> > svc 0
> > ldmfd sp!,{r4,r5,r6,r7}
> > tst lr,#1
> > + it eq
> > moveq pc,lr
> > bx lr
>
> There's a gas option -Wa,-mimplicit-it=always that will make these
> kind of changes unnecessary. I think it's preferable to just have
> musl's configure always add that option when targeting arm if it's
> accepted by the toolchain. Otherwise new code might get added without
> checking that it builds as thumb.
I dug up the changes I made to get it to build (not run; atomics.s is
broken) as thumb-only; see attached. Note that the atomics.s part of
the diff actively breaks the code so that it won't work even as arm
code.
I'll see if I can come up with a good solution for the atomics. One
thing I do need to know is how the thread pointer is supposed to be
read on cortex-m, since afaik the coprocessor register normally used
does not exist. Does the kernel trap and emulate the coprocessor
register, or is there some other mechanism that must be used?
Rich
[-- Attachment #2: thumb.diff --]
[-- Type: text/plain, Size: 1953 bytes --]
diff --git a/src/setjmp/arm/longjmp.s b/src/setjmp/arm/longjmp.s
index e28d8f3..6191ab2 100644
--- a/src/setjmp/arm/longjmp.s
+++ b/src/setjmp/arm/longjmp.s
@@ -8,7 +8,9 @@ longjmp:
mov ip,r0
movs r0,r1
moveq r0,#1
- ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp,sp,lr}
+ ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
+ ldmia ip!, {r2,lr}
+ mov sp,r2
adr r1,1f
ldr r2,1f
diff --git a/src/setjmp/arm/setjmp.s b/src/setjmp/arm/setjmp.s
index 8779163..c6fe1bb 100644
--- a/src/setjmp/arm/setjmp.s
+++ b/src/setjmp/arm/setjmp.s
@@ -9,7 +9,9 @@ __setjmp:
_setjmp:
setjmp:
mov ip,r0
- stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp,sp,lr}
+ stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp}
+ mov r2,sp
+ stmia ip!,{r2,lr}
mov r0,#0
adr r1,1f
diff --git a/src/string/arm/memcpy.c b/src/string/arm/memcpy.c
index 041614f..f703c9b 100644
--- a/src/string/arm/memcpy.c
+++ b/src/string/arm/memcpy.c
@@ -1,3 +1,3 @@
-#if __ARMEB__
+#if __ARMEB__ || __thumb__
#include "../memcpy.c"
#endif
diff --git a/src/string/arm/memcpy_le.S b/src/string/arm/memcpy_le.S
index 4db4844..9cfbcb2 100644
--- a/src/string/arm/memcpy_le.S
+++ b/src/string/arm/memcpy_le.S
@@ -1,4 +1,4 @@
-#ifndef __ARMEB__
+#if !__ARMEB__ && !__thumb__
/*
* Copyright (C) 2008 The Android Open Source Project
diff --git a/src/thread/arm/atomics.s b/src/thread/arm/atomics.s
index 673fc03..380f714 100644
--- a/src/thread/arm/atomics.s
+++ b/src/thread/arm/atomics.s
@@ -6,7 +6,7 @@
.type __a_barrier,%function
__a_barrier:
ldr ip,1f
- ldr ip,[pc,ip]
+ //ldr ip,[pc,ip]
add pc,pc,ip
1: .word __a_barrier_ptr-1b
.global __a_barrier_dummy
@@ -40,7 +40,7 @@ __a_barrier_v7:
.type __a_cas,%function
__a_cas:
ldr ip,1f
- ldr ip,[pc,ip]
+ //ldr ip,[pc,ip]
add pc,pc,ip
1: .word __a_cas_ptr-1b
.global __a_cas_dummy
@@ -85,7 +85,7 @@ __aeabi_read_tp:
.type __a_gettp,%function
__a_gettp:
ldr r0,1f
- ldr r0,[pc,r0]
+ //ldr r0,[pc,r0]
add pc,pc,r0
1: .word __a_gettp_ptr-1b
.global __a_gettp_dummy
next prev parent reply other threads:[~2016-12-09 6:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-07 5:52 Rob Landley
2016-12-07 15:29 ` Szabolcs Nagy
2016-12-07 15:35 ` Szabolcs Nagy
2016-12-08 0:55 ` Rob Landley
2016-12-08 1:16 ` Rich Felker
2016-12-08 19:10 ` Rob Landley
2016-12-08 21:01 ` Rich Felker
2016-12-08 22:36 ` Rob Landley
2016-12-13 0:29 ` Rob Landley
2016-12-13 1:48 ` Rich Felker
2016-12-20 4:23 ` Rich Felker
2016-12-07 20:19 ` Rob Landley
2016-12-08 21:11 ` Rich Felker
2016-12-09 6:33 ` Rich Felker [this message]
[not found] ` <20161208211116.GO1555-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2016-12-15 18:34 ` [musl] " Rob Landley
[not found] ` <7bfe2625-725d-d1bb-7177-f2d31ce09e9c-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2016-12-15 18:51 ` Waldemar Brodkorb
2016-12-20 7:18 ` [Buildroot] " Rob Landley
[not found] ` <48fb6c09-9dcb-e563-dc2d-f30062c5fceb-VoJi6FS/r0vR7s880joybQ@public.gmane.org>
2016-12-20 8:26 ` Thomas Petazzoni
[not found] ` <20161220092600.2ca96088-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-12-20 18:17 ` Rob Landley
2016-12-21 6:18 ` [musl] " Waldemar Brodkorb
[not found] ` <20161221061853.GB2915-zdp6y753eiWHneL7xjqqhBsWhVFi+jh/@public.gmane.org>
2016-12-27 22:03 ` Rob Landley
2016-12-18 0:29 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161209063327.GR1555@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).