Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Sep 2012 20:59:49 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r240178 - in head/lib/libc/amd64: . gen sys
Message-ID:  <201209062059.q86KxnNd083737@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Sep  6 20:59:49 2012
New Revision: 240178
URL: http://svn.freebsd.org/changeset/base/240178

Log:
  libc/amd64: Do not export .cerror.
  
  For some reason, libc exports the symbol .cerror (HIDENAME(cerror)), albeit
  in the FBSDprivate_1.0 version. It looks like there is no reason for this
  since it is not used from other libraries. Given that it cannot be accessed
  from C and its strange calling convention, it is rather unlikely that other
  things rely on it. Perhaps it is from a time when symbols could not be
  hidden.
  
  Most of the amd64 assembler code jumps to .cerror using the GOT. It can jump
  to it directly now, as in non-PIC mode.
  
  There are also some minor size optimizations to instructions but they yield
  virtually no benefit in the size of libc.so.7 due to padding.
  
  Reviewed by:	kib

Modified:
  head/lib/libc/amd64/SYS.h
  head/lib/libc/amd64/Symbol.map
  head/lib/libc/amd64/gen/rfork_thread.S
  head/lib/libc/amd64/sys/brk.S
  head/lib/libc/amd64/sys/exect.S
  head/lib/libc/amd64/sys/getcontext.S
  head/lib/libc/amd64/sys/pipe.S
  head/lib/libc/amd64/sys/ptrace.S
  head/lib/libc/amd64/sys/reboot.S
  head/lib/libc/amd64/sys/sbrk.S
  head/lib/libc/amd64/sys/setlogin.S
  head/lib/libc/amd64/sys/vfork.S

Modified: head/lib/libc/amd64/SYS.h
==============================================================================
--- head/lib/libc/amd64/SYS.h	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/SYS.h	Thu Sep  6 20:59:49 2012	(r240178)
@@ -36,38 +36,20 @@
 #include <sys/syscall.h>
 #include <machine/asm.h>
 
-#ifdef PIC
 #define	RSYSCALL(x)	ENTRY(__CONCAT(__sys_,x));			\
 			.weak CNAME(x);					\
 			.set CNAME(x),CNAME(__CONCAT(__sys_,x));	\
 			.weak CNAME(__CONCAT(_,x));			\
 			.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
-			mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \
-			2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \
+			mov __CONCAT($SYS_,x),%eax; KERNCALL;		\
+			jb HIDENAME(cerror); ret;			\
 			END(__CONCAT(__sys_,x))
 
 #define	PSEUDO(x)	ENTRY(__CONCAT(__sys_,x));			\
 			.weak CNAME(__CONCAT(_,x));			\
 			.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
-			mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret ; \
-			2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \
+			mov __CONCAT($SYS_,x),%eax; KERNCALL;		\
+			jb HIDENAME(cerror); ret;			\
 			END(__CONCAT(__sys_,x))
-#else
-#define	RSYSCALL(x)	ENTRY(__CONCAT(__sys_,x));			\
-			.weak CNAME(x);					\
-			.set CNAME(x),CNAME(__CONCAT(__sys_,x));	\
-			.weak CNAME(__CONCAT(_,x));			\
-			.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
-			mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \
-			2: jmp HIDENAME(cerror);			\
-			END(__CONCAT(__sys_,x))
-
-#define	PSEUDO(x)	ENTRY(__CONCAT(__sys_,x));			\
-			.weak CNAME(__CONCAT(_,x));			\
-			.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
-			mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \
-			2: jmp HIDENAME(cerror);			\
-			END(__CONCAT(__sys_,x))
-#endif
 
 #define KERNCALL	movq %rcx, %r10; syscall

Modified: head/lib/libc/amd64/Symbol.map
==============================================================================
--- head/lib/libc/amd64/Symbol.map	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/Symbol.map	Thu Sep  6 20:59:49 2012	(r240178)
@@ -66,7 +66,6 @@ FBSDprivate_1.0 {
 	.curbrk;
 	.minbrk;
 	_brk;
-	.cerror;
 	_end;
 	__sys_vfork;
 	_vfork;

Modified: head/lib/libc/amd64/gen/rfork_thread.S
==============================================================================
--- head/lib/libc/amd64/gen/rfork_thread.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/gen/rfork_thread.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -93,12 +93,7 @@ ENTRY(rfork_thread)
 2:
 	popq	%r12
 	popq	%rbx
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)), %rdx
-	jmp	*%rdx
-#else
 	jmp	HIDENAME(cerror)
-#endif
 END(rfork_thread)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/brk.S
==============================================================================
--- head/lib/libc/amd64/sys/brk.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/brk.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -76,12 +76,7 @@ ok:
 	ret
 err:
 	addq	$8, %rsp
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
 	jmp	HIDENAME(cerror)
-#endif
 END(brk)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/exect.S
==============================================================================
--- head/lib/libc/amd64/sys/exect.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/exect.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -47,12 +47,7 @@ ENTRY(exect)
 	pushq	%r8
 	popfq
 	KERNCALL
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
 	jmp	HIDENAME(cerror)
-#endif
 END(exect)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/getcontext.S
==============================================================================
--- head/lib/libc/amd64/sys/getcontext.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/getcontext.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -42,16 +42,9 @@ ENTRY(__sys_getcontext)
 	movq	(%rsp),%rsi	/* save getcontext return address */
 	mov	$SYS_getcontext,%rax
 	KERNCALL
-	jb	1f
+	jb	HIDENAME(cerror)
 	addq	$8,%rsp		/* remove stale (setcontext) return address */
 	jmp	*%rsi		/* restore return address */
-1:
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
-	jmp	HIDENAME(cerror)
-#endif
 END(__sys_getcontext)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/pipe.S
==============================================================================
--- head/lib/libc/amd64/sys/pipe.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/pipe.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -45,18 +45,11 @@ __FBSDID("$FreeBSD$");
 ENTRY(__sys_pipe)
 	mov	$SYS_pipe,%rax
 	KERNCALL
-	jb	1f
+	jb	HIDENAME(cerror)
 	movl	%eax,(%rdi)	/* %rdi is preserved by syscall */
 	movl	%edx,4(%rdi)
 	movq	$0,%rax
 	ret
-1:
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
-	jmp	HIDENAME(cerror)
-#endif
 END(__sys_pipe)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/ptrace.S
==============================================================================
--- head/lib/libc/amd64/sys/ptrace.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/ptrace.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -48,15 +48,8 @@ ENTRY(ptrace)
 #endif
 	mov	$SYS_ptrace,%eax
 	KERNCALL
-	jb	err
+	jb	HIDENAME(cerror)
 	ret
-err:
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
-	jmp	HIDENAME(cerror)
-#endif
 END(ptrace)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/reboot.S
==============================================================================
--- head/lib/libc/amd64/sys/reboot.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/reboot.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -45,15 +45,8 @@ __FBSDID("$FreeBSD$");
 ENTRY(__sys_reboot)
 	mov	$SYS_reboot,%rax
 	KERNCALL
-	jb	1f
+	jb	HIDENAME(cerror)
 	iretq
-1:
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
-	jmp	HIDENAME(cerror)
-#endif
 END(__sys_reboot)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/sbrk.S
==============================================================================
--- head/lib/libc/amd64/sys/sbrk.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/sbrk.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -79,12 +79,7 @@ back:
 	ret
 err:
 	addq	$8, %rsp
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
 	jmp	HIDENAME(cerror)
-#endif
 END(sbrk)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/setlogin.S
==============================================================================
--- head/lib/libc/amd64/sys/setlogin.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/setlogin.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
 ENTRY(__sys_setlogin)
 	mov	$SYS_setlogin,%rax
 	KERNCALL
-	jb	1f
+	jb	HIDENAME(cerror)
 #ifdef PIC
 	movq	PIC_GOT(CNAME(_logname_valid)),%rdx
 	movl	$0,(%rdx)
@@ -55,13 +55,6 @@ ENTRY(__sys_setlogin)
 	movl	$0,CNAME(_logname_valid)(%rip)
 #endif
 	ret				/* setlogin(name) */
-1:
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
-	jmp	HIDENAME(cerror)
-#endif
 END(__sys_setlogin)
 
 	.section .note.GNU-stack,"",%progbits

Modified: head/lib/libc/amd64/sys/vfork.S
==============================================================================
--- head/lib/libc/amd64/sys/vfork.S	Thu Sep  6 20:16:59 2012	(r240177)
+++ head/lib/libc/amd64/sys/vfork.S	Thu Sep  6 20:59:49 2012	(r240178)
@@ -50,12 +50,7 @@ ENTRY(__sys_vfork)
 	jmp	*%rsi
 1:
 	pushq	%rsi
-#ifdef PIC
-	movq	PIC_GOT(HIDENAME(cerror)),%rdx
-	jmp	*%rdx
-#else
 	jmp	HIDENAME(cerror)
-#endif
 END(__sys_vfork)
 
 	.section .note.GNU-stack,"",%progbits



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209062059.q86KxnNd083737>