diff options
author | peter <peter@FreeBSD.org> | 2003-05-24 17:35:23 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-05-24 17:35:23 +0000 |
commit | 6afa41d48f5917e806ea16b805c4fe1d6cb70ce1 (patch) | |
tree | 62d6d8570db0fa33690f62a994b8b67c4eae07e7 /lib/libc/amd64 | |
parent | dc5114efb5a7accba1140bb50db1def228a37531 (diff) | |
download | FreeBSD-src-6afa41d48f5917e806ea16b805c4fe1d6cb70ce1.zip FreeBSD-src-6afa41d48f5917e806ea16b805c4fe1d6cb70ce1.tar.gz |
Repair PIC mode. It seems I was a bit too excited about the
implications of native PC relative addressing.
Diffstat (limited to 'lib/libc/amd64')
-rw-r--r-- | lib/libc/amd64/SYS.h | 13 | ||||
-rw-r--r-- | lib/libc/amd64/sys/brk.S | 27 | ||||
-rw-r--r-- | lib/libc/amd64/sys/exect.S | 7 | ||||
-rw-r--r-- | lib/libc/amd64/sys/ptrace.S | 14 | ||||
-rw-r--r-- | lib/libc/amd64/sys/sbrk.S | 27 | ||||
-rw-r--r-- | lib/libc/amd64/sys/setlogin.S | 7 | ||||
-rw-r--r-- | lib/libc/amd64/sys/vfork.S | 9 |
7 files changed, 89 insertions, 15 deletions
diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 5dc8b46..46aeb47 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -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 diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S index 0192b04..7d755e6 100644 --- a/lib/libc/amd64/sys/brk.S +++ b/lib/libc/amd64/sys/brk.S @@ -51,17 +51,36 @@ ENTRY(_brk) 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 diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S index 180a309..d71a94b 100644 --- a/lib/libc/amd64/sys/exect.S +++ b/lib/libc/amd64/sys/exect.S @@ -51,4 +51,9 @@ ENTRY(exect) 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 diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S index e6587e7..f0b86f4 100644 --- a/lib/libc/amd64/sys/ptrace.S +++ b/lib/libc/amd64/sys/ptrace.S @@ -44,10 +44,20 @@ __FBSDID("$FreeBSD$"); 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 diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S index dcdc513..dde1bcd 100644 --- a/lib/libc/amd64/sys/sbrk.S +++ b/lib/libc/amd64/sys/sbrk.S @@ -54,19 +54,38 @@ HIDENAME(curbrk): .quad CNAME(_end) 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 diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S index 54acef8..cb355d2 100644 --- a/lib/libc/amd64/sys/setlogin.S +++ b/lib/libc/amd64/sys/setlogin.S @@ -45,5 +45,10 @@ __FBSDID("$FreeBSD$"); .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) */ diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S index b3fc3cf..fe9313e 100644 --- a/lib/libc/amd64/sys/vfork.S +++ b/lib/libc/amd64/sys/vfork.S @@ -53,5 +53,10 @@ ENTRY(__sys_vfork) 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 |