From: Jaydeep Patil <Jaydeep.Patil@imgtec.com>
To: "dalias@libc.org" <dalias@libc.org>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>,
"nsz@port70.net" <nsz@port70.net>
Subject: [MUSL] microMIPS32R2 O32 port
Date: Wed, 5 Apr 2017 06:33:01 +0000 [thread overview]
Message-ID: <BD7773622145634B952E5B54ACA8E349DAE2BD60@PUMAIL01.pu.imgtec.org> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1027 bytes --]
Hi Rich,
Please refer to https://github.com/JaydeepIMG/musl-1/tree/micromips32r2_v1 for microMIPS32R2 O32 port. I have also attached the patch (microMIPS32R2_v1_port.patch) for your reference.
Could you please review it?
Test result:
FAIL ./src/api/main.exe [status 1]
FAIL ./src/math/acosh.exe [status 1]
FAIL ./src/math/acoshl.exe [status 1]
FAIL ./src/math/asinh.exe [status 1]
FAIL ./src/math/asinhl.exe [status 1]
FAIL ./src/math/j0.exe [status 1]
FAIL ./src/math/jn.exe [status 1]
FAIL ./src/math/jnf.exe [status 1]
FAIL ./src/math/lgamma.exe [status 1]
FAIL ./src/math/lgamma_r.exe [status 1]
FAIL ./src/math/lgammaf.exe [status 1]
FAIL ./src/math/lgammaf_r.exe [status 1]
FAIL ./src/math/lgammal.exe [status 1]
FAIL ./src/math/sinh.exe [status 1]
FAIL ./src/math/sinhl.exe [status 1]
FAIL ./src/math/tgamma.exe [status 1]
FAIL ./src/math/tgammal.exe [status 1]
FAIL ./src/math/y0.exe [status 1]
FAIL ./src/math/y0f.exe [status 1]
FAIL ./src/math/ynf.exe [status 1]
Thanks,
Jaydeep
[-- Attachment #1.2: Type: text/html, Size: 3893 bytes --]
[-- Attachment #2: microMIPS32R2_v1_port.patch --]
[-- Type: application/octet-stream, Size: 10018 bytes --]
diff --git a/arch/mips/crt_arch.h b/arch/mips/crt_arch.h
index 9fc50d7..c95db06 100644
--- a/arch/mips/crt_arch.h
+++ b/arch/mips/crt_arch.h
@@ -8,13 +8,39 @@ __asm__(
".type " START ", @function\n"
"_" START ":\n"
"" START ":\n"
+#if __mips_isa_rev < 6
+#ifdef __mips_micromips
+" move $fp, $0 \n"
+" .align 2 \n"
+" bal32 1f \n"
+" nop32 \n"
+#else
" bal 1f \n"
" move $fp, $0 \n"
+#endif
+#else
+" move $fp, $0 \n"
+" .align 2 \n"
+" balc 1f \n"
+#endif
" .gpword . \n"
" .gpword " START "_c \n"
".weak _DYNAMIC \n"
".hidden _DYNAMIC \n"
" .gpword _DYNAMIC \n"
+
+#ifdef __mips_micromips
+"1: ins $ra, $0, 0, 1 \n"
+" lw $gp, 0($ra) \n"
+" subu $gp, $ra, $gp \n"
+" move $4, $sp \n"
+" lw $5, 8($ra) \n"
+" addu $5, $5, $gp \n"
+" lw $25, 4($ra) \n"
+" addu $25, $25, $gp \n"
+" ori $25, $25, 1 \n"
+" and $sp, $sp, -8 \n"
+#else
"1: lw $gp, 0($ra) \n"
" subu $gp, $ra, $gp \n"
" move $4, $sp \n"
@@ -23,7 +49,14 @@ __asm__(
" lw $25, 4($ra) \n"
" addu $25, $25, $gp \n"
" and $sp, $sp, -8 \n"
+#endif
+
+#if __mips_isa_rev < 6
" jalr $25 \n"
" subu $sp, $sp, 16 \n"
+#else
+" subu $sp, $sp, 16 \n"
+" jalrc $25 \n"
+#endif
".set pop \n"
);
diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
index b3d59a4..9b5a4d7 100644
--- a/arch/mips/reloc.h
+++ b/arch/mips/reloc.h
@@ -36,6 +36,26 @@
#define CRTJMP(pc,sp) __asm__ __volatile__( \
"move $sp,%1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
+#if __mips_isa_rev < 6
+#ifdef __mips_micromips
+#define GETFUNCSYM(fp, sym, got) __asm__ ( \
+ ".hidden " #sym "\n" \
+ ".set push \n" \
+ ".set noreorder \n" \
+ " .align 2 \n" \
+ " bal32 1f \n" \
+ " nop32 \n" \
+ " .gpword . \n" \
+ " .gpword " #sym " \n" \
+ "1: ins $ra, $0, 0, 1 \n" \
+ " lw %0, ($ra) \n" \
+ " subu %0, $ra, %0 \n" \
+ " lw $ra, 4($ra) \n" \
+ " addu %0, %0, $ra \n" \
+ " ori %0, %0, 1 \n" \
+ ".set pop \n" \
+ : "=r"(*(fp)) : : "memory", "ra" )
+#else
#define GETFUNCSYM(fp, sym, got) __asm__ ( \
".hidden " #sym "\n" \
".set push \n" \
@@ -50,3 +70,38 @@
" addu %0, %0, $ra \n" \
".set pop \n" \
: "=r"(*(fp)) : : "memory", "ra" )
+#endif
+#else
+#ifdef __mips_micromips
+#define GETFUNCSYM(fp, sym, got) __asm__ ( \
+ ".hidden " #sym "\n" \
+ ".set push \n" \
+ ".set noreorder \n" \
+ " .align 2 \n" \
+ " balc32 1f \n" \
+ " .gpword . \n" \
+ " .gpword " #sym " \n" \
+ "1: ins $ra, $0, 0, 1 \n" \
+ " lw %0, ($ra) \n" \
+ " subu %0, $ra, %0 \n" \
+ " lw $ra, 4($ra) \n" \
+ " addu %0, %0, $ra \n" \
+ " ori %0, %0, 1 \n" \
+ ".set pop \n" \
+ : "=r"(*(fp)) : : "memory", "ra" )
+#else
+#define GETFUNCSYM(fp, sym, got) __asm__ ( \
+ ".hidden " #sym "\n" \
+ ".set push \n" \
+ ".set noreorder \n" \
+ " balc 1f \n" \
+ " .gpword . \n" \
+ " .gpword " #sym " \n" \
+ "1: lw %0, ($ra) \n" \
+ " subu %0, $ra, %0 \n" \
+ " lw $ra, 4($ra) \n" \
+ " addu %0, %0, $ra \n" \
+ ".set pop \n" \
+ : "=r"(*(fp)) : : "memory", "ra" )
+#endif
+#endif
diff --git a/crt/mips/crtn.s b/crt/mips/crtn.s
index 506a04b..10bfaa1 100644
--- a/crt/mips/crtn.s
+++ b/crt/mips/crtn.s
@@ -3,11 +3,13 @@
.section .init
lw $gp,24($sp)
lw $ra,28($sp)
- j $ra
addu $sp,$sp,32
+ j $ra
+ nop
.section .fini
lw $gp,24($sp)
lw $ra,28($sp)
- j $ra
addu $sp,$sp,32
+ j $ra
+ nop
diff --git a/src/fenv/mips/fenv.S b/src/fenv/mips/fenv.S
index a5cb1f5..b0548ac 100644
--- a/src/fenv/mips/fenv.S
+++ b/src/fenv/mips/fenv.S
@@ -10,8 +10,9 @@ feclearexcept:
or $5, $5, $4
xor $5, $5, $4
ctc1 $5, $31
- jr $ra
li $2, 0
+ jr $ra
+ nop
.global feraiseexcept
.type feraiseexcept,@function
@@ -20,23 +21,26 @@ feraiseexcept:
cfc1 $5, $31
or $5, $5, $4
ctc1 $5, $31
- jr $ra
li $2, 0
+ jr $ra
+ nop
.global fetestexcept
.type fetestexcept,@function
fetestexcept:
and $4, $4, 0x7c
cfc1 $2, $31
- jr $ra
and $2, $2, $4
+ jr $ra
+ nop
.global fegetround
.type fegetround,@function
fegetround:
cfc1 $2, $31
- jr $ra
andi $2, $2, 3
+ jr $ra
+ nop
.global __fesetround
.type __fesetround,@function
@@ -46,16 +50,18 @@ __fesetround:
and $5, $5, $6
or $5, $5, $4
ctc1 $5, $31
- jr $ra
li $2, 0
+ jr $ra
+ nop
.global fegetenv
.type fegetenv,@function
fegetenv:
cfc1 $5, $31
sw $5, 0($4)
- jr $ra
li $2, 0
+ jr $ra
+ nop
.global fesetenv
.type fesetenv,@function
@@ -65,7 +71,8 @@ fesetenv:
nop
lw $5, 0($4)
1: ctc1 $5, $31
- jr $ra
li $2, 0
+ jr $ra
+ nop
#endif
diff --git a/src/internal/mips/syscall.s b/src/internal/mips/syscall.s
index 5d0def5..e6cb8fb 100644
--- a/src/internal/mips/syscall.s
+++ b/src/internal/mips/syscall.s
@@ -19,8 +19,9 @@ __syscall:
sw $2 ,28($sp)
lw $2, 28($sp)
syscall
- beq $7, $0, 1f
addu $sp, $sp, 32
+ beq $7, $0, 1f
+ nop
subu $2, $0, $2
1: jr $ra
nop
diff --git a/src/ldso/mips/dlsym.s b/src/ldso/mips/dlsym.s
index 1573e51..dd68a8f 100644
--- a/src/ldso/mips/dlsym.s
+++ b/src/ldso/mips/dlsym.s
@@ -13,5 +13,6 @@ dlsym:
jalr $25
nop
lw $ra, 12($sp)
- jr $ra
addiu $sp, $sp, 16
+ jr $ra
+ nop
diff --git a/src/setjmp/mips/longjmp.S b/src/setjmp/mips/longjmp.S
index fdb6c95..b1572c3 100644
--- a/src/setjmp/mips/longjmp.S
+++ b/src/setjmp/mips/longjmp.S
@@ -36,5 +36,6 @@ longjmp:
lw $22, 32($4)
lw $23, 36($4)
lw $30, 40($4)
- jr $ra
lw $28, 44($4)
+ jr $ra
+ nop
diff --git a/src/setjmp/mips/setjmp.S b/src/setjmp/mips/setjmp.S
index 501d526..e45c77d 100644
--- a/src/setjmp/mips/setjmp.S
+++ b/src/setjmp/mips/setjmp.S
@@ -35,5 +35,6 @@ setjmp:
swc1 $30, 96($4)
swc1 $31, 100($4)
#endif
- jr $ra
li $2, 0
+ jr $ra
+ nop
diff --git a/src/signal/mips/sigsetjmp.s b/src/signal/mips/sigsetjmp.s
index 74b65ff..6d7b605 100644
--- a/src/signal/mips/sigsetjmp.s
+++ b/src/signal/mips/sigsetjmp.s
@@ -8,15 +8,17 @@ sigsetjmp:
__sigsetjmp:
lui $gp, %hi(_gp_disp)
addiu $gp, %lo(_gp_disp)
+ addu $gp, $gp, $25
beq $5, $0, 1f
- addu $gp, $gp, $25
+ nop
sw $ra, 104($4)
sw $16, 104+4+16($4)
lw $25, %call16(setjmp)($gp)
+ move $16, $4
jalr $25
- move $16, $4
+ nop
move $5,$2
move $4,$16
diff --git a/src/thread/mips/clone.s b/src/thread/mips/clone.s
index 37dddf5..8e83626 100644
--- a/src/thread/mips/clone.s
+++ b/src/thread/mips/clone.s
@@ -4,7 +4,7 @@
__clone:
# Save function pointer and argument pointer on new thread stack
and $5, $5, -8
- subu $5, $5, 16
+ subu $5, $5, 32
sw $4, 0($5)
sw $7, 4($5)
# Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
@@ -19,8 +19,9 @@ __clone:
beq $7, $0, 1f
nop
addu $sp, $sp, 16
- jr $ra
subu $2, $0, $2
+ jr $ra
+ nop
1: beq $2, $0, 1f
nop
addu $sp, $sp, 16
diff --git a/src/thread/mips/syscall_cp.S b/src/thread/mips/syscall_cp.S
new file mode 100644
index 0000000..c593bcf
--- /dev/null
+++ b/src/thread/mips/syscall_cp.S
@@ -0,0 +1,85 @@
+.set noreorder
+
+.global __cp_begin
+.hidden __cp_begin
+.type __cp_begin,@function
+.global __cp_end
+.hidden __cp_end
+.type __cp_end,@function
+.global __cp_cancel
+.hidden __cp_cancel
+.type __cp_cancel,@function
+.hidden __cancel
+.global __syscall_cp_asm
+.hidden __syscall_cp_asm
+.type __syscall_cp_asm,@function
+__syscall_cp_asm:
+ subu $sp, $sp, 32
+__cp_begin:
+ lw $4, 0($4)
+ move $2, $5
+ bne $4, $0, __cp_cancel
+ nop
+ move $4, $6
+ move $5, $7
+ lw $6, 48($sp)
+ lw $7, 52($sp)
+ lw $8, 56($sp)
+ lw $9, 60($sp)
+ lw $10,64($sp)
+ sw $8, 16($sp)
+ sw $9, 20($sp)
+ sw $10,24($sp)
+ sw $2, 28($sp)
+ lw $2, 28($sp)
+ syscall
+__cp_end:
+ addu $sp, $sp, 32
+ beq $7, $0, 1f
+ nop
+ subu $2, $0, $2
+1: jr $ra
+ nop
+
+__cp_cancel:
+ move $2, $ra
+
+#if __mips_isa_rev < 6
+#ifdef __mips_micromips
+ addu $sp, $sp, 32
+ .align 2
+ bal32 1f
+ nop32
+#else
+ bal 1f
+ addu $sp, $sp, 32
+#endif
+#else
+#ifdef __mips_micromips
+ addu $sp, $sp, 32
+ .align 2
+ balc32 1f
+#else
+ addu $sp, $sp, 32
+ balc 1f
+#endif
+#endif
+ .gpword .
+ .gpword __cancel
+#ifdef __mips_micromips
+1: ins $ra, $0, 0, 1
+ lw $3, ($ra)
+ subu $3, $ra, $3
+ lw $25, 4($ra)
+ addu $25, $25, $3
+ ori $25, $25, 1
+#else
+1: lw $3, ($ra)
+ subu $3, $ra, $3
+ lw $25, 4($ra)
+ addu $25, $25, $3
+#endif
+ move $ra, $2
+ jr $25
+
+ nop
diff --git a/src/thread/mips/syscall_cp.s b/src/thread/mips/syscall_cp.s
deleted file mode 100644
index d284626..0000000
--- a/src/thread/mips/syscall_cp.s
+++ /dev/null
@@ -1,53 +0,0 @@
-.set noreorder
-
-.global __cp_begin
-.hidden __cp_begin
-.type __cp_begin,@function
-.global __cp_end
-.hidden __cp_end
-.type __cp_end,@function
-.global __cp_cancel
-.hidden __cp_cancel
-.type __cp_cancel,@function
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
- subu $sp, $sp, 32
-__cp_begin:
- lw $4, 0($4)
- bne $4, $0, __cp_cancel
- move $2, $5
- move $4, $6
- move $5, $7
- lw $6, 48($sp)
- lw $7, 52($sp)
- lw $8, 56($sp)
- lw $9, 60($sp)
- lw $10,64($sp)
- sw $8, 16($sp)
- sw $9, 20($sp)
- sw $10,24($sp)
- sw $2, 28($sp)
- lw $2, 28($sp)
- syscall
-__cp_end:
- beq $7, $0, 1f
- addu $sp, $sp, 32
- subu $2, $0, $2
-1: jr $ra
- nop
-
-__cp_cancel:
- move $2, $ra
- bal 1f
- addu $sp, $sp, 32
- .gpword .
- .gpword __cancel
-1: lw $3, ($ra)
- subu $3, $ra, $3
- lw $25, 4($ra)
- addu $25, $25, $3
- jr $25
- move $ra, $2
diff --git a/src/unistd/mips/pipe.s b/src/unistd/mips/pipe.s
index ba2c39a..e60912b 100644
--- a/src/unistd/mips/pipe.s
+++ b/src/unistd/mips/pipe.s
@@ -11,8 +11,9 @@ pipe:
beq $7, $0, 1f
nop
lw $25, %call16(__syscall_ret)($gp)
- jr $25
subu $4, $0, $2
+ jr $25
+ nop
1: sw $2, 0($4)
sw $3, 4($4)
move $2, $0
next reply other threads:[~2017-04-05 6:33 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 6:33 Jaydeep Patil [this message]
2017-04-06 16:18 ` dalias
2017-04-07 6:47 ` Jaydeep Patil
2017-04-07 14:19 ` Rich Felker
2017-04-12 11:54 ` Jaydeep Patil
2017-04-12 19:25 ` Szabolcs Nagy
2017-04-12 20:27 ` Rich Felker
2017-04-12 21:47 ` Andre McCurdy
2017-04-13 4:29 ` Jaydeep Patil
2017-04-13 9:00 ` Szabolcs Nagy
2017-04-13 10:37 ` Jaydeep Patil
2017-04-21 9:40 ` Jaydeep Patil
2017-04-21 13:33 ` Rich Felker
2017-04-24 5:30 ` Jaydeep Patil
2017-04-24 13:48 ` Rich Felker
2017-04-25 4:45 ` Jaydeep Patil
2017-04-25 16:52 ` Rich Felker
2017-04-26 7:14 ` Jaydeep Patil
2017-05-11 3:25 ` Jaydeep Patil
2017-05-17 8:28 ` Jaydeep Patil
2017-05-26 3:46 ` Jaydeep Patil
2017-05-28 2:00 ` Rich Felker
2017-05-31 13:11 ` Rich Felker
2017-06-01 4:21 ` Jaydeep Patil
2017-04-21 13:26 ` 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=BD7773622145634B952E5B54ACA8E349DAE2BD60@PUMAIL01.pu.imgtec.org \
--to=jaydeep.patil@imgtec.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=nsz@port70.net \
/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).