Update for AMD64 after repocopy from i386/sys/*. This means:

- strip out the nasty PIC_PROLOGUE/EPILOGUE stuff, since we dont have
to lose a register in PIC mode anymore (we use %rip-relative addressing).
- update for C register argument passing conventions.
- convert 32 bit to 64 bit register sizes etc.
This commit is contained in:
peter 2003-04-30 18:16:33 +00:00
parent d25ffe9c8c
commit 415054f8cb
6 changed files with 35 additions and 105 deletions

View File

@ -45,46 +45,23 @@ __FBSDID("$FreeBSD$");
.globl HIDENAME(curbrk) .globl HIDENAME(curbrk)
.globl HIDENAME(minbrk) .globl HIDENAME(minbrk)
ENTRY(_brk) ENTRY(_brk)
pushq %rdi
jmp ok jmp ok
ENTRY(brk) ENTRY(brk)
#ifdef PIC pushq %rdi
movl 4(%esp),%eax movq %rdi,%rax
PIC_PROLOGUE cmpq %rax,PIC_GOT(HIDENAME(minbrk))
movl PIC_GOT(HIDENAME(curbrk)),%edx # set up GOT addressing
movl PIC_GOT(HIDENAME(minbrk)),%ecx #
PIC_EPILOGUE
cmpl %eax,(%ecx)
jbe ok jbe ok
movl (%ecx),%eax movq PIC_GOT(HIDENAME(minbrk)),%rdi
movl %eax,4(%esp)
ok: ok:
mov $SYS_break,%eax movq $SYS_break,%rax
KERNCALL KERNCALL
jb err jb err
movl 4(%esp),%eax movq 0(%rsp),%rax
movl %eax,(%edx) movq %rax,PIC_GOT(HIDENAME(curbrk))
movl $0,%eax movq $0,%rax
popq %rdi
ret ret
err: err:
PIC_PROLOGUE
jmp PIC_PLT(HIDENAME(cerror)) jmp PIC_PLT(HIDENAME(cerror))
#else
movl 4(%esp),%eax
cmpl %eax,HIDENAME(minbrk)
jbe ok
movl HIDENAME(minbrk),%eax
movl %eax,4(%esp)
ok:
mov $SYS_break,%eax
KERNCALL
jb err
movl 4(%esp),%eax
movl %eax,HIDENAME(curbrk)
movl $0,%eax
ret
err:
jmp HIDENAME(cerror)
#endif

View File

@ -52,18 +52,11 @@ __FBSDID("$FreeBSD$");
.globl CNAME(__error) .globl CNAME(__error)
.type CNAME(__error),@function .type CNAME(__error),@function
HIDENAME(cerror): HIDENAME(cerror):
pushl %eax pushq %rax
#ifdef PIC
/* The caller must execute the PIC prologue before jumping to cerror. */
call PIC_PLT(CNAME(__error)) call PIC_PLT(CNAME(__error))
popl %ecx popq %rcx
PIC_EPILOGUE movq %rcx,(%rax)
#else movq $-1,%rax
call CNAME(__error) movq $-1,%rdx
popl %ecx
#endif
movl %ecx,(%eax)
movl $-1,%eax
movl $-1,%edx
ret ret

View File

@ -44,12 +44,11 @@ __FBSDID("$FreeBSD$");
#include <machine/psl.h> #include <machine/psl.h>
ENTRY(exect) ENTRY(exect)
mov $SYS_execve,%eax movq $SYS_execve,%rax
pushf pushfq
popl %edx popq %r8
orl $ PSL_T,%edx orq $PSL_T,%r8
pushl %edx pushq %r8
popf popfq
KERNCALL KERNCALL
PIC_PROLOGUE
jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */

View File

@ -44,18 +44,10 @@ __FBSDID("$FreeBSD$");
ENTRY(ptrace) ENTRY(ptrace)
xorl %eax,%eax xorl %eax,%eax
#ifdef PIC movl %eax,PIC_GOT(CNAME(errno))
PIC_PROLOGUE
movl PIC_GOT(CNAME(errno)),%edx
movl %eax,(%edx)
PIC_EPILOGUE
#else
movl %eax,CNAME(errno)
#endif
mov $SYS_ptrace,%eax mov $SYS_ptrace,%eax
KERNCALL KERNCALL
jb err jb err
ret ret
err: err:
PIC_PROLOGUE
jmp PIC_PLT(HIDENAME(cerror)) jmp PIC_PLT(HIDENAME(cerror))

View File

@ -47,48 +47,26 @@ __FBSDID("$FreeBSD$");
.globl HIDENAME(curbrk) .globl HIDENAME(curbrk)
.data .data
HIDENAME(minbrk): .long CNAME(_end) HIDENAME(minbrk): .quad CNAME(_end)
HIDENAME(curbrk): .long CNAME(_end) HIDENAME(curbrk): .quad CNAME(_end)
.text .text
ENTRY(sbrk) ENTRY(sbrk)
#ifdef PIC pushq %rdi
movl 4(%esp),%ecx movq %rdi,%rcx
PIC_PROLOGUE movq PIC_GOT(HIDENAME(curbrk)),%rax
movl PIC_GOT(HIDENAME(curbrk)),%edx testq %rcx,%rcx
movl (%edx),%eax
PIC_EPILOGUE
testl %ecx,%ecx
jz back jz back
addl %eax,4(%esp) addq %rax,%rdi
mov $SYS_break,%eax mov $SYS_break,%eax
KERNCALL KERNCALL
jb err jb err
PIC_PROLOGUE movq PIC_GOT(HIDENAME(curbrk)),%rax
movl PIC_GOT(HIDENAME(curbrk)),%edx movq 0(%rsp), %rcx
movl (%edx),%eax addq %rcx,PIC_GOT(HIDENAME(curbrk))
addl %ecx,(%edx)
PIC_EPILOGUE
back: back:
addq $8, %rsp
ret ret
err: err:
PIC_PROLOGUE addq $8, %rsp
jmp PIC_PLT(HIDENAME(cerror)) jmp PIC_PLT(HIDENAME(cerror))
#else /* !PIC */
movl 4(%esp),%ecx
movl HIDENAME(curbrk),%eax
testl %ecx,%ecx
jz back
addl %eax,4(%esp)
mov $SYS_break,%eax
KERNCALL
jb err
movl HIDENAME(curbrk),%eax
addl %ecx,HIDENAME(curbrk)
back:
ret
err:
jmp HIDENAME(cerror)
#endif /* PIC */

View File

@ -45,14 +45,5 @@ __FBSDID("$FreeBSD$");
.globl CNAME(_logname_valid) /* in _getlogin() */ .globl CNAME(_logname_valid) /* in _getlogin() */
SYSCALL(setlogin) SYSCALL(setlogin)
#ifdef PIC movl $0,PIC_GOT(CNAME(_logname_valid))
PIC_PROLOGUE
pushl %eax
movl PIC_GOT(CNAME(_logname_valid)),%eax
movl $0,(%eax)
popl %eax
PIC_EPILOGUE
#else
movl $0,CNAME(_logname_valid)
#endif
ret /* setlogin(name) */ ret /* setlogin(name) */