[uClibc]mips and clone.S

Scott A McConnell samcconn at cotw.com
Tue May 21 16:40:50 UTC 2002


Since no one appears to be working on this issue...

I have been working on getting clone.S built for mipsel.


I pulled over asm.h, sysdep.S and /sysdeps/unix/mips/sysdep.h (modified
this a little)
from glibc.

With the patch I have attached below I have made it to this point:


mipsel-linux-strip -x -R .note -R .comment setjmp.o
mipsel-linux-gcc -Wall -Os -falign-functions=1 -fno-builtin -nostdinc 
-nostdinc -I../../../../include
-I/opt/toolchains/mips/lib/gcc-lib/mipsel-linux/3.1/include -I. -D_LIBC 
-DNDEBUG  -fPIC -D_LIBC_REENTRANT -c clone.S -o clone.o
clone.S: Assembler messages:
clone.S:107: Error: unrecognized opcode `extern __typeof(__clone)clone
__attribute__((weak,alias("__clone")))'


-------------------------------
I tracked the above into features.h and compared the definition to what
is in glibc. It looks right.

Can anyone explain to me what it is complaining about?


-- 
Scott A. McConnell

------------------------------------------------------

diff -urN uClibc/libc/sysdeps/linux/mips/CVS/Entries
uClibc-new/libc/sysdeps/linux/mips/CVS/Entries
--- uClibc/libc/sysdeps/linux/mips/CVS/Entries	Tue May 21 11:06:36 2002
+++ uClibc-new/libc/sysdeps/linux/mips/CVS/Entries	Tue May 21 09:07:42
2002
@@ -13,5 +13,5 @@
 /vfork.c/1.1/Sat Feb 16 20:16:20 2002//
 D/bits////
 D/sys////
-/Makefile/1.13/Tue May 21 16:06:36 2002//
-/clone.S/1.1/Tue May 21 16:06:36 2002//
+/clone.S/1.1/Tue May 21 12:59:03 2002//
+/Makefile/1.13/Tue May 21 13:40:17 2002//
diff -urN uClibc/libc/sysdeps/linux/mips/Makefile
uClibc-new/libc/sysdeps/linux/mips/Makefile
--- uClibc/libc/sysdeps/linux/mips/Makefile	Tue May 21 11:06:36 2002
+++ uClibc-new/libc/sysdeps/linux/mips/Makefile	Tue May 21 10:57:25 2002
@@ -30,7 +30,7 @@
 CRT0=crt0.S
 CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
 
-SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S #fork.S clone.S
+SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S  sysdep.S #fork.S
 SOBJS=$(patsubst %.S,%.o, $(SSRC))
 
 CSRC=__longjmp.c  brk.c vfork.c setjmp_aux.c _mmap.c pipe.c
diff -urN uClibc/libc/sysdeps/linux/mips/sys/asm.h
uClibc-new/libc/sysdeps/linux/mips/sys/asm.h
--- uClibc/libc/sysdeps/linux/mips/sys/asm.h	Wed Dec 31 18:00:00 1969
+++ uClibc-new/libc/sysdeps/linux/mips/sys/asm.h	Fri May 17 14:57:02
2002
@@ -0,0 +1,377 @@
+/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ralf Baechle <ralf at gnu.org>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_ASM_H
+#define _SYS_ASM_H
+
+#include <sgidefs.h>
+
+#ifndef CAT
+#ifdef __STDC__
+#define __CAT(str1,str2) str1##str2
+#else
+#define __CAT(str1,str2) str1/**/str2
+#endif
+#define CAT(str1,str2) __CAT(str1,str2)
+#endif
+
+/*
+ * Macros to handle different pointer/register sizes for 32/64-bit code
+ *
+ * 64 bit address space isn't used yet, so we may use the R3000 32 bit
+ * defines for now.
+ */
+#define PTR	.word
+#define PTRSIZE	4
+#define PTRLOG	2
+
+/*
+ * PIC specific declarations
+ */
+#ifdef __PIC__
+#define CPRESTORE(register)                             \
+		.cprestore register
+#define CPADD(register)                                 \
+		.cpadd	register
+#define CPLOAD(register)                                \
+		.cpload	register
+#else
+#define CPRESTORE(register)
+#define CPADD(register)
+#define CPLOAD(register)
+#endif
+
+/*
+ * LEAF - declare leaf routine
+ */
+#define	LEAF(symbol)                                    \
+		.globl	symbol;                         \
+		.align	2;                              \
+		.type	symbol, at function;               \
+		.ent	symbol,0;                       \
+symbol:		.frame	sp,0,ra
+
+/*
+ * NESTED - declare nested routine entry point
+ */
+#define	NESTED(symbol, framesize, rpc)                  \
+		.globl	symbol;                         \
+		.align	2;                              \
+		.type	symbol, at function;               \
+		.ent	symbol,0;                       \
+symbol:		.frame	sp, framesize, rpc
+
+/*
+ * END - mark end of function
+ */
+#define	END(function)                                   \
+		.end	function;		        \
+		.size	function,.-function
+
+/*
+ * EXPORT - export definition of symbol
+ */
+#define	EXPORT(symbol)                                  \
+		.globl	symbol;                         \
+symbol:
+
+/*
+ * ABS - export absolute symbol
+ */
+#define	ABS(symbol,value)                               \
+		.globl	symbol;                         \
+symbol		=	value
+
+#define	PANIC(msg)                                      \
+		.set	push;				\
+		.set	reorder;                        \
+		la	a0,8f;                          \
+		jal	panic;                          \
+9:		b	9b;                             \
+		.set	pop;				\
+		TEXT(msg)
+
+/*
+ * Print formated string
+ */
+#define PRINT(string)                                   \
+		.set	push;				\
+		.set	reorder;                        \
+		la	a0,8f;                          \
+		jal	printk;                         \
+		.set	pop;				\
+		TEXT(string)
+
+#define	TEXT(msg)                                       \
+		.data;                                  \
+8:		.asciiz	msg;                            \
+		.previous;
+
+/*
+ * Build text tables
+ */
+#define TTABLE(string)                                  \
+		.text;                                  \
+		.word	1f;                             \
+		.previous;                              \
+		.data;                                  \
+1:		.asciz	string;                         \
+		.previous
+
+/*
+ * MIPS IV pref instruction.
+ * Use with .set noreorder only!
+ *
+ * MIPS IV implementations are free to treat this as a nop.  The R5000
+ * is one of them.  So we should have an option not to use this
instruction.
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
+#define PREF(hint,addr)                                 \
+		pref	hint,addr
+#define PREFX(hint,addr)                                \
+		prefx	hint,addr
+#else
+#define PREF
+#define PREFX
+#endif
+
+/*
+ * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
+ */
+#if _MIPS_ISA == _MIPS_ISA_MIPS1
+#define MOVN(rd,rs,rt)                                  \
+		.set	push;				\
+		.set	reorder;			\
+		beqz	rt,9f;                          \
+		move	rd,rs;                          \
+		.set	pop;				\
+9:
+#define MOVZ(rd,rs,rt)                                  \
+		.set	push;				\
+		.set	reorder;			\
+		bnez	rt,9f;                          \
+		move	rd,rt;                          \
+		.set	pop;				\
+9:
+#endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
+#define MOVN(rd,rs,rt)                                  \
+		.set	push;				\
+		.set	noreorder;			\
+		bnezl	rt,9f;                          \
+		move	rd,rs;                          \
+		.set	pop;				\
+9:
+#define MOVZ(rd,rs,rt)                                  \
+		.set	push;				\
+		.set	noreorder;			\
+		beqzl	rt,9f;                          \
+		movz	rd,rs;                          \
+		.set	pop;				\
+9:
+#endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA ==
_MIPS_ISA_MIPS3) */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5)
+#define MOVN(rd,rs,rt)                                  \
+		movn	rd,rs,rt
+#define MOVZ(rd,rs,rt)                                  \
+		movz	rd,rs,rt
+#endif /* (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA ==
_MIPS_ISA_MIPS5) */
+
+/*
+ * Stack alignment
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
+#define ALSZ	7
+#define ALMASK	~7
+#endif
+#if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) ||
\
+    (_MIPS_ISA == _MIPS_ISA_MIPS5)
+#define ALSZ	15
+#define ALMASK	~15
+#endif
+
+/*
+ * Size of a register
+ */
+#ifdef __mips64
+#define SZREG	8
+#else
+#define SZREG	4
+#endif
+
+/*
+ * Use the following macros in assemblercode to load/store registers,
+ * pointers etc.
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
+#define REG_S sw
+#define REG_L lw
+#define PTR_SUBU subu
+#define PTR_ADDU addu
+#endif
+#if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) ||
\
+    (_MIPS_ISA == _MIPS_ISA_MIPS5)
+#define REG_S sd
+#define REG_L ld
+/* We still live in a 32 bit address space ...  */
+#define PTR_SUBU subu
+#define PTR_ADDU addu
+#endif
+
+/*
+ * How to add/sub/load/store/shift C int variables.
+ */
+#if (_MIPS_SZINT == 32)
+#define INT_ADD	add
+#define INT_ADDI	addi
+#define INT_ADDU	addu
+#define INT_ADDIU	addiu
+#define INT_SUB	add
+#define INT_SUBI	subi
+#define INT_SUBU	subu
+#define INT_SUBIU	subu
+#define INT_L		lw
+#define INT_S		sw
+#define LONG_SLL	sll
+#define LONG_SLLV	sllv
+#define LONG_SRL	srl
+#define LONG_SRLV	srlv
+#define LONG_SRA	sra
+#define LONG_SRAV	srav
+#endif
+
+#if (_MIPS_SZINT == 64)
+#define INT_ADD	dadd
+#define INT_ADDI	daddi
+#define INT_ADDU	daddu
+#define INT_ADDIU	daddiu
+#define INT_SUB	dadd
+#define INT_SUBI	dsubi
+#define INT_SUBU	dsubu
+#define INT_SUBIU	dsubu
+#define INT_L		ld
+#define INT_S		sd
+#define LONG_SLL	dsll
+#define LONG_SLLV	dsllv
+#define LONG_SRL	dsrl
+#define LONG_SRLV	dsrlv
+#define LONG_SRA	dsra
+#define LONG_SRAV	dsrav
+#endif
+
+/*
+ * How to add/sub/load/store/shift C long variables.
+ */
+#if (_MIPS_SZLONG == 32)
+#define LONG_ADD	add
+#define LONG_ADDI	addi
+#define LONG_ADDU	addu
+#define LONG_ADDIU	addiu
+#define LONG_SUB	add
+#define LONG_SUBI	subi
+#define LONG_SUBU	subu
+#define LONG_SUBIU	subu
+#define LONG_L		lw
+#define LONG_S		sw
+#define LONG_SLL	sll
+#define LONG_SLLV	sllv
+#define LONG_SRL	srl
+#define LONG_SRLV	srlv
+#define LONG_SRA	sra
+#define LONG_SRAV	srav
+#endif
+
+#if (_MIPS_SZLONG == 64)
+#define LONG_ADD	dadd
+#define LONG_ADDI	daddi
+#define LONG_ADDU	daddu
+#define LONG_ADDIU	daddiu
+#define LONG_SUB	dadd
+#define LONG_SUBI	dsubi
+#define LONG_SUBU	dsubu
+#define LONG_SUBIU	dsubu
+#define LONG_L		ld
+#define LONG_S		sd
+#define LONG_SLL	dsll
+#define LONG_SLLV	dsllv
+#define LONG_SRL	dsrl
+#define LONG_SRLV	dsrlv
+#define LONG_SRA	dsra
+#define LONG_SRAV	dsrav
+#endif
+
+/*
+ * How to add/sub/load/store/shift pointers.
+ */
+#if (_MIPS_SZLONG == 32)
+#define PTR_ADD	add
+#define PTR_ADDI	addi
+#define PTR_ADDU	addu
+#define PTR_ADDIU	addiu
+#define PTR_SUB		add
+#define PTR_SUBI	subi
+#define PTR_SUBU	subu
+#define PTR_SUBIU	subu
+#define PTR_L		lw
+#define PTR_S		sw
+#define PTR_SLL		sll
+#define PTR_SLLV	sllv
+#define PTR_SRL		srl
+#define PTR_SRLV	srlv
+#define PTR_SRA		sra
+#define PTR_SRAV	srav
+
+#define PTR_SCALESHIFT	2
+#endif
+
+#if (_MIPS_SZLONG == 64)
+#define PTR_ADD	dadd
+#define PTR_ADDI	daddi
+#define PTR_ADDU	daddu
+#define PTR_ADDIU	daddiu
+#define PTR_SUB		dadd
+#define PTR_SUBI	dsubi
+#define PTR_SUBU	dsubu
+#define PTR_SUBIU	dsubu
+#define PTR_L		ld
+#define PTR_S		sd
+#define PTR_SLL		dsll
+#define PTR_SLLV	dsllv
+#define PTR_SRL		dsrl
+#define PTR_SRLV	dsrlv
+#define PTR_SRA		dsra
+#define PTR_SRAV	dsrav
+
+#define PTR_SCALESHIFT	3
+#endif
+
+/*
+ * Some cp0 registers were extended to 64bit for MIPS III.
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
+#define MFC0	mfc0
+#define MTC0	mtc0
+#endif
+#if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) ||
\
+    (_MIPS_ISA == _MIPS_ISA_MIPS5)
+#define MFC0	dmfc0
+#define MTC0	dmtc0
+#endif
+
+#endif /* sys/asm.h */
diff -urN uClibc/libc/sysdeps/linux/mips/sysdep.S
uClibc-new/libc/sysdeps/linux/mips/sysdep.S
--- uClibc/libc/sysdeps/linux/mips/sysdep.S	Wed Dec 31 18:00:00 1969
+++ uClibc-new/libc/sysdeps/linux/mips/sysdep.S	Tue May 21 10:57:04 2002
@@ -0,0 +1,101 @@
+/* Copyright (C) 1992,93,94,97,98,99,2000 Free Software Foundation,
Inc.
+   This file is part of the GNU C Library.
+   Contributed by Brendan Kehoe (brendan at zen.org).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <bits/errno.h>
+
+#ifdef _LIBC_REENTRANT
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+	.set noreorder
+	.set	noat
+	move	$1, $31
+	bltzal	$0, 0f
+	nop
+0:	.cpload	$31
+	move	$31, $1
+	.set	at
+	.set	reorder
+#endif
+	subu	sp, 32
+#ifdef __PIC__
+	.cprestore 16
+#endif
+	sw	v0, 20(sp)
+	sw	ra, 24(sp)
+
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+	/* We translate the system's EWOULDBLOCK error into EAGAIN.
+	   The GNU C library always defines EWOULDBLOCK==EAGAIN.
+	   EWOULDBLOCK_sys is the original number.  */
+	bne	v0, EWOULDBLOCK_sys, skip
+	nop
+	li	v0, EAGAIN
+skip:
+#endif
+	/* Store it in the "real" variable ... */
+	sw v0, errno
+
+	/* Find our per-thread errno address  */
+	jal	__errno_location
+
+	/* Store the error value.  */
+	lw	t0, 20(sp)
+	sw	t0, 0(v0)
+
+	/* And just kick back a -1.  */
+	lw	ra, 24(sp)
+	addiu	sp, 32
+	li	v0, -1
+	j	ra
+	END(__syscall_error)
+
+#else /* _LIBC_REENTRANT */
+
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+	.set	noreorder
+	.set	noat
+	move	$1, $31
+	bltzal	$0, 0f
+	nop
+0:	.cpload	$31
+	move	$31, $1
+	.set	at
+	.set	reorder
+#endif
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+	/* We translate the system's EWOULDBLOCK error into EAGAIN.
+	   The GNU C library always defines EWOULDBLOCK==EAGAIN.
+	   EWOULDBLOCK_sys is the original number.  */
+	bne v0, EWOULDBLOCK_sys, skip
+	li v0, EAGAIN
+skip:
+#endif
+	/* Store it in errno... */
+	sw v0, errno
+
+	/* And just kick back a -1.  */
+	li v0, -1
+	j ra
+	END(__syscall_error)
+#endif  /* _LIBC_REENTRANT  */
diff -urN uClibc/libc/sysdeps/linux/mips/sysdep.h
uClibc-new/libc/sysdeps/linux/mips/sysdep.h
--- uClibc/libc/sysdeps/linux/mips/sysdep.h	Wed Dec 31 18:00:00 1969
+++ uClibc-new/libc/sysdeps/linux/mips/sysdep.h	Tue May 21 09:53:52 2002
@@ -0,0 +1,82 @@
+/* Copyright (C) 1992,95,97,99,2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Brendan Kehoe (brendan at zen.org).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* Changed code for uClib from glibc */
+
+/* include <sysdeps/unix/sysdep.h> */
+
+#include "bits/syscalls.h"
+#include <sys/asm.h>
+
+/* End of changed code for uClibc. */
+
+#ifdef __ASSEMBLER__
+
+#include <regdef.h>
+
+#define ENTRY(name) \
+  .globl name;								      \
+  .align 2;								      \
+  .ent name,0;								      \
+  name##:
+
+/* Note that while it's better structurally, going back to call
__syscall_error
+   can make things confusing if you're debugging---it looks like it's
jumping
+   backwards into the previous fn.  */
+#ifdef __PIC__
+ #define PSEUDO(name, syscall_name, args) \
+  .align 2;								      \
+  99: la t9,__syscall_error;						      \
+  jr t9;								      \
+  ENTRY(name)								      \
+  .set noreorder;							      \
+  .cpload t9;								      \
+  li v0, SYS_ify(syscall_name);						      \
+  syscall;								      \
+  .set reorder;								      \
+  bne a3, zero, 99b;							      \
+syse1:
+#else
+#define PSEUDO(name, syscall_name, args) \
+  .set noreorder;							      \
+  .align 2;								      \
+  99: j __syscall_error;							      \
+  ENTRY(name)								      \
+  .set noreorder;							      \
+  li v0, SYS_ify(syscall_name);						      \
+  syscall;								      \
+  .set reorder;								      \
+  bne a3, zero, 99b;							      \
+syse1:
+#endif
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym) .end sym
+
+#define ret	j ra ; nop
+
+#undef END
+#define END(sym)        .end sym
+
+#define r0	v0
+#define r1	v1
+/* The mips move insn is d,s.  */
+#define MOVE(x,y)	move y , x
+
+#endif



More information about the uClibc mailing list