From owner-svn-src-all@FreeBSD.ORG Wed Sep 5 21:41:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BD2BC1065672; Wed, 5 Sep 2012 21:41:06 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A74A98FC1B; Wed, 5 Sep 2012 21:41:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q85Lf6d4006345; Wed, 5 Sep 2012 21:41:06 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q85Lf6Mn006333; Wed, 5 Sep 2012 21:41:06 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201209052141.q85Lf6Mn006333@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 5 Sep 2012 21:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240152 - in head/lib/libc/i386: . gen sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2012 21:41:06 -0000 Author: jilles Date: Wed Sep 5 21:41:05 2012 New Revision: 240152 URL: http://svn.freebsd.org/changeset/base/240152 Log: libc/i386: 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. Not exporting .cerror causes it to be jumped to directly instead of via the PLT. This change also takes advantage of .cerror's new status by not saving and loading %ebx before jumping to it. (Therefore, .cerror now saves and loads %ebx itself.) Where there was a conditional jump to a jump to .cerror, the conditional jump has been changed to jump to .cerror directly (many modern CPUs don't do static prediction and in any case it is not much of a benefit anyway). This change makes libc.so.7 a few kilobytes smaller. Reviewed by: kib Modified: head/lib/libc/i386/SYS.h head/lib/libc/i386/Symbol.map head/lib/libc/i386/gen/rfork_thread.S head/lib/libc/i386/sys/Ovfork.S head/lib/libc/i386/sys/brk.S head/lib/libc/i386/sys/cerror.S head/lib/libc/i386/sys/exect.S head/lib/libc/i386/sys/getcontext.S head/lib/libc/i386/sys/ptrace.S head/lib/libc/i386/sys/sbrk.S head/lib/libc/i386/sys/syscall.S Modified: head/lib/libc/i386/SYS.h ============================================================================== --- head/lib/libc/i386/SYS.h Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/SYS.h Wed Sep 5 21:41:05 2012 (r240152) @@ -36,21 +36,21 @@ #include #include -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(__sys_,x)); \ +#define SYSCALL(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),%eax; KERNCALL; jb 2b + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror) #define RSYSCALL(x) SYSCALL(x); ret; END(__CONCAT(__sys_,x)) -#define PSEUDO(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__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),%eax; KERNCALL; jb 2b; ret; \ + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror); ret; \ END(__CONCAT(__sys_,x)) /* gas messes up offset -- although we don't currently need it, do for BCS */ Modified: head/lib/libc/i386/Symbol.map ============================================================================== --- head/lib/libc/i386/Symbol.map Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/Symbol.map Wed Sep 5 21:41:05 2012 (r240152) @@ -63,7 +63,6 @@ FBSDprivate_1.0 { __sys_vfork; _vfork; _end; - .cerror; _brk; .curbrk; .minbrk; Modified: head/lib/libc/i386/gen/rfork_thread.S ============================================================================== --- head/lib/libc/i386/gen/rfork_thread.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/gen/rfork_thread.S Wed Sep 5 21:41:05 2012 (r240152) @@ -113,8 +113,7 @@ ENTRY(rfork_thread) popl %esi movl %ebp, %esp popl %ebp - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) + jmp HIDENAME(cerror) END(rfork_thread) .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/sys/Ovfork.S ============================================================================== --- head/lib/libc/i386/sys/Ovfork.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/Ovfork.S Wed Sep 5 21:41:05 2012 (r240152) @@ -50,8 +50,7 @@ ENTRY(__sys_vfork) jmp *%ecx 1: pushl %ecx - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) + jmp HIDENAME(cerror) END(__sys_vfork) .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/sys/brk.S ============================================================================== --- head/lib/libc/i386/sys/brk.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/brk.S Wed Sep 5 21:41:05 2012 (r240152) @@ -58,14 +58,11 @@ ENTRY(brk) ok: mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl 4(%esp),%eax movl %eax,(%edx) movl $0,%eax ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) #else @@ -77,13 +74,11 @@ err: ok: mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl 4(%esp),%eax movl %eax,HIDENAME(curbrk) movl $0,%eax ret -err: - jmp HIDENAME(cerror) #endif END(brk) Modified: head/lib/libc/i386/sys/cerror.S ============================================================================== --- head/lib/libc/i386/sys/cerror.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/cerror.S Wed Sep 5 21:41:05 2012 (r240152) @@ -48,13 +48,14 @@ __FBSDID("$FreeBSD$"); .globl CNAME(__error) .type CNAME(__error),@function HIDENAME(cerror): - pushl %eax #ifdef PIC - /* The caller must execute the PIC prologue before jumping to cerror. */ + PIC_PROLOGUE + pushl %eax call PIC_PLT(CNAME(__error)) popl %ecx PIC_EPILOGUE #else + pushl %eax call CNAME(__error) popl %ecx #endif Modified: head/lib/libc/i386/sys/exect.S ============================================================================== --- head/lib/libc/i386/sys/exect.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/exect.S Wed Sep 5 21:41:05 2012 (r240152) @@ -47,8 +47,7 @@ ENTRY(exect) pushl %edx popf KERNCALL - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ + jmp HIDENAME(cerror) /* exect(file, argv, env); */ END(exect) .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/sys/getcontext.S ============================================================================== --- head/lib/libc/i386/sys/getcontext.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/getcontext.S Wed Sep 5 21:41:05 2012 (r240152) @@ -42,12 +42,9 @@ ENTRY(__sys_getcontext) movl (%esp),%ecx /* save getcontext return address */ mov $SYS_getcontext,%eax KERNCALL - jb 1f + jb HIDENAME(cerror) addl $4,%esp /* remove stale (setcontext) return address */ jmp *%ecx /* restore return address */ -1: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(__sys_getcontext) .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/sys/ptrace.S ============================================================================== --- head/lib/libc/i386/sys/ptrace.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/ptrace.S Wed Sep 5 21:41:05 2012 (r240152) @@ -50,11 +50,8 @@ ENTRY(ptrace) #endif mov $SYS_ptrace,%eax KERNCALL - jb err + jb HIDENAME(cerror) ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(ptrace) .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/sys/sbrk.S ============================================================================== --- head/lib/libc/i386/sys/sbrk.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/sbrk.S Wed Sep 5 21:41:05 2012 (r240152) @@ -59,7 +59,7 @@ ENTRY(sbrk) addl %eax,4(%esp) mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) PIC_PROLOGUE movl PIC_GOT(HIDENAME(curbrk)),%edx movl (%edx),%eax @@ -67,9 +67,6 @@ ENTRY(sbrk) PIC_EPILOGUE back: ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) #else /* !PIC */ @@ -80,13 +77,11 @@ err: addl %eax,4(%esp) mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl HIDENAME(curbrk),%eax addl %ecx,HIDENAME(curbrk) back: ret -err: - jmp HIDENAME(cerror) #endif /* PIC */ END(sbrk) Modified: head/lib/libc/i386/sys/syscall.S ============================================================================== --- head/lib/libc/i386/sys/syscall.S Wed Sep 5 20:40:11 2012 (r240151) +++ head/lib/libc/i386/sys/syscall.S Wed Sep 5 21:41:05 2012 (r240152) @@ -45,11 +45,8 @@ ENTRY(syscall) KERNCALL push %ecx /* need to push a word to keep stack frame intact upon return; the word must be the return address. */ - jb 1f + jb HIDENAME(cerror) ret -1: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(syscall) .section .note.GNU-stack,"",%progbits