diff options
author | jilles <jilles@FreeBSD.org> | 2012-09-06 20:59:49 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2012-09-06 20:59:49 +0000 |
commit | bd7319c0d8e9fd3f2becfb5f5c255627f777b178 (patch) | |
tree | 52129e8c46adddfb2fbbbad68f2b439bbbed0bec /lib/libc/amd64 | |
parent | 0bc0a2586ce9caa8fbee0c1f134bff3f6dec4f15 (diff) | |
download | FreeBSD-src-bd7319c0d8e9fd3f2becfb5f5c255627f777b178.zip FreeBSD-src-bd7319c0d8e9fd3f2becfb5f5c255627f777b178.tar.gz |
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
Diffstat (limited to 'lib/libc/amd64')
-rw-r--r-- | lib/libc/amd64/SYS.h | 26 | ||||
-rw-r--r-- | lib/libc/amd64/Symbol.map | 1 | ||||
-rw-r--r-- | lib/libc/amd64/gen/rfork_thread.S | 5 | ||||
-rw-r--r-- | lib/libc/amd64/sys/brk.S | 5 | ||||
-rw-r--r-- | lib/libc/amd64/sys/exect.S | 5 | ||||
-rw-r--r-- | lib/libc/amd64/sys/getcontext.S | 9 | ||||
-rw-r--r-- | lib/libc/amd64/sys/pipe.S | 9 | ||||
-rw-r--r-- | lib/libc/amd64/sys/ptrace.S | 9 | ||||
-rw-r--r-- | lib/libc/amd64/sys/reboot.S | 9 | ||||
-rw-r--r-- | lib/libc/amd64/sys/sbrk.S | 5 | ||||
-rw-r--r-- | lib/libc/amd64/sys/setlogin.S | 9 | ||||
-rw-r--r-- | lib/libc/amd64/sys/vfork.S | 5 |
12 files changed, 9 insertions, 88 deletions
diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 61d7ab4..a232383 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -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 diff --git a/lib/libc/amd64/Symbol.map b/lib/libc/amd64/Symbol.map index 9997cc2..bbf6113 100644 --- a/lib/libc/amd64/Symbol.map +++ b/lib/libc/amd64/Symbol.map @@ -66,7 +66,6 @@ FBSDprivate_1.0 { .curbrk; .minbrk; _brk; - .cerror; _end; __sys_vfork; _vfork; diff --git a/lib/libc/amd64/gen/rfork_thread.S b/lib/libc/amd64/gen/rfork_thread.S index 9720e08..5e764db 100644 --- a/lib/libc/amd64/gen/rfork_thread.S +++ b/lib/libc/amd64/gen/rfork_thread.S @@ -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 diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S index 2319417..4048ae6 100644 --- a/lib/libc/amd64/sys/brk.S +++ b/lib/libc/amd64/sys/brk.S @@ -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 diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S index 81dc8e5..04a97ed 100644 --- a/lib/libc/amd64/sys/exect.S +++ b/lib/libc/amd64/sys/exect.S @@ -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 diff --git a/lib/libc/amd64/sys/getcontext.S b/lib/libc/amd64/sys/getcontext.S index ea29adb..1128796 100644 --- a/lib/libc/amd64/sys/getcontext.S +++ b/lib/libc/amd64/sys/getcontext.S @@ -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 diff --git a/lib/libc/amd64/sys/pipe.S b/lib/libc/amd64/sys/pipe.S index 59c1ac1c..8d089db 100644 --- a/lib/libc/amd64/sys/pipe.S +++ b/lib/libc/amd64/sys/pipe.S @@ -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 diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S index 6235390..9c4628d 100644 --- a/lib/libc/amd64/sys/ptrace.S +++ b/lib/libc/amd64/sys/ptrace.S @@ -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 diff --git a/lib/libc/amd64/sys/reboot.S b/lib/libc/amd64/sys/reboot.S index e79ca79..fd04ef4 100644 --- a/lib/libc/amd64/sys/reboot.S +++ b/lib/libc/amd64/sys/reboot.S @@ -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 diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S index 3e4d8aa..0332aae 100644 --- a/lib/libc/amd64/sys/sbrk.S +++ b/lib/libc/amd64/sys/sbrk.S @@ -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 diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S index 23692b9..a451491 100644 --- a/lib/libc/amd64/sys/setlogin.S +++ b/lib/libc/amd64/sys/setlogin.S @@ -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 diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S index 555c3ca..2afba58 100644 --- a/lib/libc/amd64/sys/vfork.S +++ b/lib/libc/amd64/sys/vfork.S @@ -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 |