Browse Source

Remove TEXTREL relocations for ARM.
Hide __syscall_error from outside libc.
From Peter Mazinger.

Joakim Tjernlund 19 years ago
parent
commit
569b0e03fb

+ 1 - 1
libc/sysdeps/linux/arm/Makefile

@@ -28,7 +28,7 @@ SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
 	bsd-_setjmp.S sigrestorer.S mmap64.S
 SOBJS=$(patsubst %.S,%.o, $(SSRC))
 
-CSRC=brk.c syscall.c ioperm.c sigaction.c
+CSRC=brk.c syscall.c ioperm.c sigaction.c __syscall_error.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 
 OBJS=$(SOBJS) $(COBJS)

+ 5 - 1
libc/sysdeps/linux/arm/bsd-_setjmp.S

@@ -30,5 +30,9 @@
 .align 4;
 _setjmp:
 	mov	r1, #0
-	b	__sigsetjmp (PLT)
+#ifdef __PIC__
+	b	__sigsetjmp(PLT)
+#else
+	b	__sigsetjmp
+#endif
 .size _setjmp,.-_setjmp;

+ 5 - 1
libc/sysdeps/linux/arm/bsd-setjmp.S

@@ -30,5 +30,9 @@
 .align 4;
 setjmp:
 	mov	r1, #1
-	b	__sigsetjmp (PLT)
+#ifdef __PIC__
+	b	__sigsetjmp(PLT)
+#else
+	b	__sigsetjmp
+#endif
 .size setjmp,.-setjmp;

+ 20 - 25
libc/sysdeps/linux/arm/clone.S

@@ -20,21 +20,23 @@
 /* clone() is even more special than fork() as it mucks with stacks
    and invokes a function in the right context after its all over.  */
 
-#include <asm/errno.h>
+#define _ERRNO_H
+#include <bits/errno.h>
 #include <sys/syscall.h>
 
+#ifdef __NR_clone
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
 
-.text
-.globl __clone;
-.type __clone,%function
-.align 4;
+	.text
+	.globl __clone
+	.type __clone,%function
+	.align 4
 __clone:
 	@ sanity check args
 	cmp	r0, #0
 	cmpne	r1, #0
 	moveq	r0, #-EINVAL
-	beq	__syscall_error (PLT)
+	beq	__error
 
 	@ insert the args onto the new stack
 	sub	r1, r1, #8
@@ -48,7 +50,7 @@ __clone:
 	@ new sp is already in r1
 	swi	__NR_clone
 	movs	a1, a1
-	blt	__syscall_error  (PLT)
+	blt	__error
 	movne    pc, lr
 
 	@ pick the function arg and call address off the stack and execute
@@ -57,25 +59,18 @@ __clone:
 	ldr 	pc, [sp]
 
 	@ and we are done, passing the return value through r0
-	b	_exit	(PLT)
+#ifdef __PIC__
+	b	_exit(PLT)
+#else
+	b	_exit
+#endif
 
-__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
+__error:
+	b	__syscall_error
 
-	/* errno = -result */
-	str  r2, [r9,r3]
+	.size __clone,.-__clone
 
-	/* return -1 */
-	mvn  r0, $0
-	mov  pc, lr
-.size __clone,.-__clone;
-
-.L4:  .word errno
-
-
-.globl	clone;
-    clone = __clone
+	.weak clone
+	clone = __clone
 
+#endif

+ 13 - 22
libc/sysdeps/linux/arm/mmap64.S

@@ -16,20 +16,18 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#define _ERRNO_H	1
 #include <features.h>
+#define _ERRNO_H
 #include <bits/errno.h>
 #include <sys/syscall.h>
 
 #if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2
 
-
 	/* The mmap2 system call takes six arguments, all in registers.  */
 	.text
-	.global mmap64;
+	.global mmap64
 	.type mmap64,%function
-	.align 4;
-
+	.align 4
 mmap64:
 	stmfd	sp!, {r4, r5, lr}
 	ldr	r5, [sp, $16]
@@ -47,33 +45,26 @@ mmap64:
 	ldmccfd	sp!, {r4, r5, pc}
 	cmn	r0, $ENOSYS
 	ldmnefd	sp!, {r4, r5, lr}
-	bne	__syscall_error (PLT)
+	bne	__error
 	/* The current kernel does not support mmap2.  Fall back to plain
 	   mmap if the offset is small enough.  */
 	ldr	r5, [sp, $20]
 	mov	r0, ip			@ first arg was clobbered
 	teq	r5, $0
 	ldmeqfd	sp!, {r4, r5, lr}
-	beq	mmap (PLT)
+#ifdef __PIC__
+	beq	mmap(PLT)
+#else
+	beq	mmap
+#endif
 .Linval:
 	mov	r0, $-EINVAL
 	ldmfd	sp!, {r4, r5, lr}
-	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]
+	b	__error
 
-	/* return -1 */
-	mvn  r0, $0
-	mov  pc, lr
-.size mmap64,.-mmap64;
+__error:
+	b	__syscall_error
 
-.L4:  .word errno
+	.size mmap64,.-mmap64
 
 #endif

+ 5 - 1
libc/sysdeps/linux/arm/setjmp.S

@@ -38,5 +38,9 @@ __sigsetjmp:
 	sub     r0, r0, #48
 
 	/* Make a tail call to __sigjmp_save; it takes the same args.  */
-	B	__sigjmp_save	(PLT)
+#ifdef __PIC__
+	B	__sigjmp_save(PLT)
+#else
+	B	__sigjmp_save
+#endif
 .size __sigsetjmp,.-__sigsetjmp;

+ 24 - 39
libc/sysdeps/linux/arm/vfork.S

@@ -20,52 +20,37 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include <asm/errno.h>
+#define _ERRNO_H
+#include <bits/errno.h>
 #include <sys/syscall.h>
 
-
-
-		.text
-		.global vfork;
-		.type vfork,%function
-		.align 4;                                                               \
-
-
-
+#ifdef __NR_fork
+	.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     __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_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
+	/* Syscal worked.  Return to child/parent */
+	movcc   pc, lr
 
+__error:
+	b	__syscall_error
 
+	.size vfork,.-vfork
+#endif

+ 1 - 1
libc/sysdeps/linux/mips/__syscall_error.c

@@ -21,7 +21,7 @@
 
 /* This routine is jumped to by all the syscall handlers, to stash
  * an error number into errno.  */
-int __syscall_error (int err_no)
+int attribute_hidden __syscall_error (int err_no)
 {
 	__set_errno (err_no);
 	return -1;

+ 1 - 1
libc/sysdeps/linux/powerpc/__syscall_error.c

@@ -21,7 +21,7 @@
 
 /* This routine is jumped to by all the syscall handlers, to stash
  * an error number into errno.  */
-int __syscall_error (int err_no)
+int attribute_hidden __syscall_error (int err_no)
 {
 	__set_errno (err_no);
 	return -1;

+ 4 - 6
libc/sysdeps/linux/powerpc/__uClibc_syscall.S

@@ -1,14 +1,12 @@
-.section ".text"
+	.text
 	.align 2
-.globl __uClibc_syscall
+	.globl __uClibc_syscall
 	.type	__uClibc_syscall,@function
 __uClibc_syscall:
 .Lsize:
 	sc
 	bnslr
-#ifdef __PIC__
-	b	__syscall_error@plt
-#else
+
 	b	__syscall_error
-#endif
+
 	.size	__uClibc_syscall,.Lsize-__uClibc_syscall

+ 9 - 11
libc/sysdeps/linux/powerpc/brk.S

@@ -24,10 +24,10 @@
 
 #ifdef __NR_brk
 	.comm	__curbrk,4,4
-	.section ".text"
-.globl      __brk;
-.type      __brk, @function;
-.align  2;
+	.text
+	.globl	__brk
+	.type	__brk,@function
+	.align	2
 
 __brk:
 	stwu    r1,-16(r1)
@@ -51,13 +51,11 @@ __brk:
 	li	r3,0
 	blelr+
 	li      r3,ENOMEM
-#ifdef __PIC__
-	b	__syscall_error@plt
-#else
+
 	b	__syscall_error
-#endif
-.size __brk,.-__brk
 
-.weak brk;
-brk=__brk        
+	.size __brk,.-__brk
+
+	.weak brk
+	brk=__brk        
 #endif	

+ 8 - 15
libc/sysdeps/linux/powerpc/clone.S

@@ -30,10 +30,9 @@
    		  int flags [r5], void *arg [r6]); */
 
 #ifdef __NR_clone
-.globl      __clone;
-.type      __clone, @function;
-.align  2;
-
+	.globl __clone
+	.type __clone,@function
+	.align 2
 
 __clone:
 	/* Check for child_stack == NULL || fn == NULL.  */
@@ -90,21 +89,15 @@ __clone:
 	lmw	r29,16(r1)
 	addi	r1,r1,32
 	bnslr+
-#ifdef __PIC__
-	b	__syscall_error@plt
-#else
+
 	b	__syscall_error
-#endif
 
 .Lbadargs:
 	li	r3,EINVAL
-#ifdef __PIC__
-	b	__syscall_error@plt
-#else
+
 	b	__syscall_error
-#endif
 
-.size __clone,.-__clone
-.weak clone;
-clone=__clone
+	.size __clone,.-__clone
+	.weak clone
+	clone=__clone
 #endif

+ 6 - 13
libc/sysdeps/linux/powerpc/syscall.S

@@ -18,14 +18,10 @@
 
 #include <features.h>
 
-	.section ".text"
-	.globl	syscall;
-	.type	syscall,@function;
-	.align  2;
-
-.globl syscall;
-.type syscall,@function;
-.align 2;
+	.text
+	.globl	syscall
+	.type	syscall,@function
+	.align  2
 
 syscall:
 	mr 0,3
@@ -36,10 +32,7 @@ syscall:
 	mr 7,8
 	sc
 	bnslr;
-#ifdef __PIC__
-	b __syscall_error@plt
-#else
+
 	b __syscall_error
-#endif
 
-.size syscall,.-syscall
+	.size syscall,.-syscall