PERFORCE change 31759 for review
Peter Wemm
peter at FreeBSD.org
Fri May 23 20:50:14 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=31759
Change 31759 by peter at peter_hammer on 2003/05/23 20:49:49
Oh, I was feeling so smug when I removed the PIC ifdefs.
The only problem was that it was illegal and gas/ld didn't
complain about it. GRRR.
Affected files ...
.. //depot/projects/hammer/lib/libc/amd64/SYS.h#4 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/brk.S#5 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/exect.S#6 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/ptrace.S#5 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/sbrk.S#5 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/setlogin.S#5 edit
.. //depot/projects/hammer/lib/libc/amd64/sys/vfork.S#4 edit
Differences ...
==== //depot/projects/hammer/lib/libc/amd64/SYS.h#4 (text+ko) ====
@@ -40,13 +40,24 @@
#include <sys/syscall.h>
#include <machine/asm.h>
-#define SYSCALL(x) 2: jmp PIC_PLT(HIDENAME(cerror)); \
+#ifdef PIC
+#define SYSCALL(x) 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; \
+ jmp *%rcx; \
+ 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 2b
+#else
+#define SYSCALL(x) 2: jmp HIDENAME(cerror); \
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 2b
+#endif
#define RSYSCALL(x) SYSCALL(x); ret
==== //depot/projects/hammer/lib/libc/amd64/sys/brk.S#5 (text+ko) ====
@@ -51,17 +51,36 @@
ENTRY(brk)
pushq %rdi
movq %rdi,%rax
- cmpq %rax,PIC_GOT(HIDENAME(minbrk))
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(minbrk)),%rdx
+ cmpq %rax,(%rdx)
+#else
+ cmpq %rax,HIDENAME(minbrk)(%rip)
+#endif
jbe ok
- movq PIC_GOT(HIDENAME(minbrk)),%rdi
+#ifdef PIC
+ movq (%rdx),%rdi
+#else
+ movq HIDENAME(minbrk)(%rip),%rdi
+#endif
ok:
movq $SYS_break,%rax
KERNCALL
jb err
movq 0(%rsp),%rax
- movq %rax,PIC_GOT(HIDENAME(curbrk))
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(curbrk)),%rdx
+ movq %rax,(%rdx)
+#else
+ movq %rax,HIDENAME(curbrk)(%rip)
+#endif
movq $0,%rax
popq %rdi
ret
err:
- jmp PIC_PLT(HIDENAME(cerror))
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(cerror)),%rdx
+ jmp *%rdx
+#else
+ jmp HIDENAME(cerror)
+#endif
==== //depot/projects/hammer/lib/libc/amd64/sys/exect.S#6 (text+ko) ====
@@ -51,4 +51,9 @@
pushq %r8
popfq
KERNCALL
- jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(cerror)),%rdx
+ jmp *%rdx
+#else
+ jmp HIDENAME(cerror)
+#endif
==== //depot/projects/hammer/lib/libc/amd64/sys/ptrace.S#5 (text+ko) ====
@@ -44,10 +44,20 @@
ENTRY(ptrace)
xorl %eax,%eax
- movl %eax,PIC_GOT(CNAME(errno))
+#ifdef PIC
+ movq PIC_GOT(CNAME(errno)),%r8
+ movl %eax,(%r8)
+#else
+ movl %eax,CNAME(errno)(%rip)
+#endif
mov $SYS_ptrace,%eax
KERNCALL
jb err
ret
err:
- jmp PIC_PLT(HIDENAME(cerror))
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(cerror)),%rdx
+ jmp *%rdx
+#else
+ jmp HIDENAME(cerror)
+#endif
==== //depot/projects/hammer/lib/libc/amd64/sys/sbrk.S#5 (text+ko) ====
@@ -54,19 +54,38 @@
ENTRY(sbrk)
pushq %rdi
movq %rdi,%rcx
- movq PIC_GOT(HIDENAME(curbrk)),%rax
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(curbrk)),%rdx
+ movq (%rdx),%rax
+#else
+ movq HIDENAME(curbrk)(%rip),%rax
+#endif
testq %rcx,%rcx
jz back
addq %rax,%rdi
mov $SYS_break,%eax
KERNCALL
jb err
- movq PIC_GOT(HIDENAME(curbrk)),%rax
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(curbrk)),%rdx
+ movq (%rdx),%rax
+#else
+ movq HIDENAME(curbrk)(%rip),%rax
+#endif
movq 0(%rsp), %rcx
- addq %rcx,PIC_GOT(HIDENAME(curbrk))
+#ifdef PIC
+ addq %rcx,(%rdx)
+#else
+ addq %rcx,HIDENAME(curbrk)(%rip)
+#endif
back:
addq $8, %rsp
ret
err:
addq $8, %rsp
- jmp PIC_PLT(HIDENAME(cerror))
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(cerror)),%rdx
+ jmp *%rdx
+#else
+ jmp HIDENAME(cerror)
+#endif
==== //depot/projects/hammer/lib/libc/amd64/sys/setlogin.S#5 (text+ko) ====
@@ -45,5 +45,10 @@
.globl CNAME(_logname_valid) /* in _getlogin() */
SYSCALL(setlogin)
- movl $0,PIC_GOT(CNAME(_logname_valid))
+#ifdef PIC
+ movq PIC_GOT(CNAME(_logname_valid)),%rdx
+ movl $0,(%rdx)
+#else
+ movl $0,CNAME(_logname_valid)(%rip)
+#endif
ret /* setlogin(name) */
==== //depot/projects/hammer/lib/libc/amd64/sys/vfork.S#4 (text+ko) ====
@@ -53,5 +53,10 @@
jb 1f
jmp *%rsi
1:
- pushq %rcx
- jmp PIC_PLT(HIDENAME(cerror))
+ pushq %rsi
+#ifdef PIC
+ movq PIC_GOT(HIDENAME(cerror)),%rdx
+ jmp *%rdx
+#else
+ jmp HIDENAME(cerror)
+#endif
More information about the p4-projects
mailing list