[uClibc] Re: non-PIC ARM assembly

Peter S. Mazinger ps.m at gmx.net
Thu Jun 9 18:17:48 UTC 2005


You are completely right about non-PIC code, clone.S/mmap64.S/vfork.S 
produce. Currently in gentoo-land we have 2 corrections, one done by 
Mike Frysinger (vapier), the other by me. Haven't tested Mike's version, 
mine is running on a v4 LE removing all off the text relocations from 
uclibc. I attach both of them, if you have arm asm knowledge, please 
review them, correct them, and provide them ;)

Thanks, Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2
-------------- next part --------------
--- uClibc-0.9.27/libc/sysdeps/linux/arm/clone.S.mps	2005-03-19 13:50:05 +0100
+++ uClibc-0.9.27/libc/sysdeps/linux/arm/clone.S	2005-03-19 13:50:29 +0100
@@ -73,7 +73,7 @@
 	mov  pc, lr
 .size __clone,.-__clone;
 
-.L4:  .word errno
+.L4:  .word errno (GOTOFF)
 
 
 .globl	clone;
--- uClibc-0.9.27/libc/sysdeps/linux/arm/vfork.S.mps	2005-03-19 13:50:37 +0100
+++ uClibc-0.9.27/libc/sysdeps/linux/arm/vfork.S	2005-03-19 13:57:44 +0100
@@ -42,7 +42,7 @@
 		/* Check if vfork even exists.  */
 		ldr     r1, =-ENOSYS
 		teq     r0, r1
-		bne     __syscall_error
+		bne     __syscall_error (PLT)
 #endif
 
 		/* If we don't have vfork, use fork.  */
@@ -66,6 +66,6 @@
 		mvn  r0, $0
 		mov  pc, lr
 
-.L4:  .word errno
+.L4:  .word errno (GOTOFF)
 
 
--- uClibc-0.9.27/libc/sysdeps/linux/arm/mmap64.S.mps	2005-03-19 13:57:53 +0100
+++ uClibc-0.9.27/libc/sysdeps/linux/arm/mmap64.S	2005-03-19 14:08:07 +0100
@@ -74,6 +74,6 @@
 	mov  pc, lr
 .size mmap64,.-mmap64;
 
-.L4:  .word errno
+.L4:  .word errno (GOTOFF)
 
 #endif
-------------- next part --------------
--- /mnt/ftp/cvsroot/uclibc/uClibc/libc/sysdeps/linux/arm/clone.S	2005-02-08 20:55:39 +0100
+++ clone.S	2005-06-09 20:13:26 +0200
@@ -60,22 +60,24 @@
 	b	_exit	(PLT)
 
 __syscall_error:
-	/* Looks like the syscall choked -- set errno */
-	ldr  r3, .L4
-	/* Calculate the - of the syscall result, in case we need it */
-	rsb  r2, r0, $0
 
-	/* errno = -result */
-	str  r2, [r9,r3]
+	/* Looks like the syscall choked -- set errno */
+//	bl     __errno_location
+//	bl     __set_errno
+	ldr    sl, .L4
+	ldr    r2, .L4+4
+	ldr    r2, [sl, r2]
+	str    r3, [r2, #0]
 
 	/* return -1 */
-	mvn  r0, $0
-	mov  pc, lr
-.size __clone,.-__clone;
+	mvn    r0, $0
+	mov    pc, lr
 
-.L4:  .word errno
+.L4:
+	.word _GLOBAL_OFFSET_TABLE_
+	.word errno(GOT)
 
+.size __clone,.-__clone;
 
-.globl	clone;
-    clone = __clone
-
+.globl clone;
+	clone = __clone
--- /mnt/ftp/cvsroot/uclibc/uClibc/libc/sysdeps/linux/arm/mmap64.S	2005-02-08 20:55:39 +0100
+++ mmap64.S	2005-06-09 20:13:26 +0200
@@ -23,12 +23,11 @@
 
 #if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2
 
-
-	/* The mmap2 system call takes six arguments, all in registers.  */
-	.text
-	.global mmap64;
-	.type mmap64,%function
-	.align 4;
+/* The mmap2 system call takes six arguments, all in registers.  */
+.text
+.global mmap64;
+.type mmap64,%function
+.align 4;
 
 mmap64:
 	stmfd	sp!, {r4, r5, lr}
@@ -61,19 +60,23 @@
 	b	__syscall_error (PLT)
 
 __syscall_error:
-	/* Looks like the syscall choked -- set errno */
-	ldr  r3, .L4
-	/* Calculate the - of the syscall result, in case we need it */
-	rsb  r2, r0, $0
 
-	/* errno = -result */
-	str  r2, [r9,r3]
+	/* Looks like the syscall choked -- set errno */
+//	bl     __errno_location
+//	bl     __set_errno
+	ldr    sl, .L4
+	ldr    r2, .L4+4
+	ldr    r2, [sl, r2]
+	str    r3, [r2, #0]
 
 	/* return -1 */
-	mvn  r0, $0
-	mov  pc, lr
-.size mmap64,.-mmap64;
+	mvn    r0, $0
+	mov    pc, lr
+
+.L4:
+	.word _GLOBAL_OFFSET_TABLE_
+	.word errno(GOT)
 
-.L4:  .word errno
+.size mmap64,.-mmap64;
 
 #endif
--- /mnt/ftp/cvsroot/uclibc/uClibc/libc/sysdeps/linux/arm/vfork.S	2005-02-08 20:55:38 +0100
+++ vfork.S	2005-06-09 20:13:26 +0200
@@ -23,49 +23,48 @@
 #include <asm/errno.h>
 #include <sys/syscall.h>
 
+/* pid_t vfork(void); */
 
-
-		.text
-		.global vfork;
-		.type vfork,%function
-		.align 4;                                                               \
-
-
+.text
+.global vfork;
+.type vfork,%function
+.align 4
 
 vfork:
-
 #ifdef __NR_vfork
-		swi		__NR_vfork
-		cmn		r0, #4096
-		movcc	pc, lr
-
-		/* Check if vfork even exists.  */
-		ldr     r1, =-ENOSYS
-		teq     r0, r1
-		bne     __syscall_error
+	swi    __NR_vfork
+	cmn    r0, #4096
+	movcc  pc, lr
+
+	/* Check if vfork even exists */
+	ldr    r1, =-ENOSYS
+	teq    r0, r1
+	bne    __syscall_error
 #endif
 
-		/* If we don't have vfork, use fork.  */
-		swi     __NR_fork
-		cmn     r0, #4096
+	/* If we don't have vfork, use fork */
+	swi    __NR_fork
+	cmn    r0, #4096
 
-		/* Syscal worked.  Return to child/parent */
-		movcc   pc, lr
+	/* Syscall worked, return to child/parent */
+	movcc  pc, lr
 
 __syscall_error:
 
-		/* Looks like the syscall choked -- set errno */
-		ldr  r3, .L4
-		/* Calculate the - of the syscall result, in case we need it */
-		rsb  r2, r0, $0
-
-		/* errno = -result */
-		str  r2, [r9,r3]
-
-		/* return -1 */
-		mvn  r0, $0
-		mov  pc, lr
-
-.L4:  .word errno
-
+	/* Looks like the syscall choked -- set errno */
+//	bl     __errno_location
+//	bl     __set_errno
+	ldr    sl, .L4
+	ldr    r2, .L4+4
+	ldr    r2, [sl, r2]
+	str    r3, [r2, #0]
+
+	/* return -1 */
+	mvn    r0, $0
+	mov    pc, lr
+
+.L4:
+	.word _GLOBAL_OFFSET_TABLE_
+	.word errno(GOT)
 
+.size vfork,.-vfork;


More information about the uClibc mailing list