change amd64's MACHINE_ARCH from x86_64 to amd64. There are many many
reasons for this, quite a few of them technical, and not all of them
in response to Intel's broken ia32e crud. The gcc toolchain stays at
x86_64 for now.
···11-/* $OpenBSD: crt0.c,v 1.1 2004/01/28 01:46:17 mickey Exp $ */
22-/*
33- * Copyright (c) 1995 Christopher G. Demetriou
44- * All rights reserved.
55- *
66- * Redistribution and use in source and binary forms, with or without
77- * modification, are permitted provided that the following conditions
88- * are met:
99- * 1. Redistributions of source code must retain the above copyright
1010- * notice, this list of conditions and the following disclaimer.
1111- * 2. Redistributions in binary form must reproduce the above copyright
1212- * notice, this list of conditions and the following disclaimer in the
1313- * documentation and/or other materials provided with the distribution.
1414- * 3. All advertising materials mentioning features or use of this software
1515- * must display the following acknowledgement:
1616- * This product includes software developed by Christopher G. Demetriou
1717- * for the NetBSD Project.
1818- * 4. The name of the author may not be used to endorse or promote products
1919- * derived from this software without specific prior written permission
2020- *
2121- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2222- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2323- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2424- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2525- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2626- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2727- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2828- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2929- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3030- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131- */
3232-3333-#if defined(LIBC_SCCS) && !defined(lint)
3434-static char rcsid[] = "$OpenBSD: crt0.c,v 1.1 2004/01/28 01:46:17 mickey Exp $";
3535-#endif /* LIBC_SCCS and not lint */
3636-3737-#include <sys/param.h>
3838-#include <stdlib.h>
3939-4040-static char *_strrchr(char *, char);
4141-4242-char **environ;
4343-char *__progname = "";
4444-4545-char __progname_storage[NAME_MAX+1];
4646-4747-#ifdef MCRT0
4848-extern void monstartup(u_long, u_long);
4949-extern void _mcleanup(void);
5050-extern unsigned char _etext, _eprol;
5151-#endif /* MCRT0 */
5252-5353-__asm(" .text ;\
5454- .align 8 ;\
5555- .globl __start ;\
5656- .globl _start ;\
5757-_start: ;\
5858-__start: ;\
5959- movq %rbx,%r9 ;\
6060- movq %rcx,%r8 ;\
6161- movq %rdx,%rcx ;\
6262- movq (%rsp),%rdi ;\
6363- leaq 16(%rsp,%rdi,8),%rdx ;\
6464- leaq 8(%rsp),%rsi ;\
6565- subq $8,%rsp ;\
6666- andq $~15,%rsp ;\
6767- addq $8,%rsp ;\
6868- jmp ___start ;\
6969-");
7070-7171-void
7272-___start(argc, argv, envp, cleanup, obj, ps_strings)
7373- int argc;
7474- char **argv;
7575- char ** envp;
7676- void (*cleanup)(void); /* from shared loader */
7777- const void *obj; /* from shared loader */
7878- struct ps_strings *ps_strings;
7979-{
8080- char *namep;
8181- register struct kframe *kfp;
8282- char *s;
8383-8484- environ = envp;
8585-8686- if ((namep = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
8787- if ((__progname = _strrchr(namep, '/')) == NULL)
8888- __progname = namep;
8989- else
9090- ++__progname;
9191- for (s = __progname_storage; *__progname &&
9292- s < &__progname_storage[sizeof __progname_storage - 1]; )
9393- *s++ = *__progname++;
9494- *s = '\0';
9595- __progname = __progname_storage;
9696- }
9797-9898-#ifdef MCRT0
9999- atexit(_mcleanup);
100100- monstartup((u_long)&_eprol, (u_long)&_etext);
101101-#endif
102102-103103- __init();
104104-105105- exit(main(argc, argv, environ));
106106-}
107107-108108-109109-static char *
110110-_strrchr(p, ch)
111111-register char *p, ch;
112112-{
113113- register char *save;
114114-115115- for (save = NULL;; ++p) {
116116- if (*p == ch)
117117- save = (char *)p;
118118- if (!*p)
119119- return(save);
120120- }
121121-/* NOTREACHED */
122122-}
123123-124124-#ifdef MCRT0
125125-asm (" .text");
126126-asm ("_eprol:");
127127-#endif
128128-
-61
lib/csu/x86_64/md_init.h
···11-/* $OpenBSD: md_init.h,v 1.1 2004/01/28 01:46:17 mickey Exp $ */
22-33-/*-
44- * Copyright (c) 2001 Ross Harvey
55- * All rights reserved.
66- *
77- * Redistribution and use in source and binary forms, with or without
88- * modification, are permitted provided that the following conditions
99- * are met:
1010- * 1. Redistributions of source code must retain the above copyright
1111- * notice, this list of conditions and the following disclaimer.
1212- * 2. Redistributions in binary form must reproduce the above copyright
1313- * notice, this list of conditions and the following disclaimer in the
1414- * documentation and/or other materials provided with the distribution.
1515- * 3. All advertising materials mentioning features or use of this software
1616- * must display the following acknowledgement:
1717- * This product includes software developed by the NetBSD
1818- * Foundation, Inc. and its contributors.
1919- * 4. Neither the name of The NetBSD Foundation nor the names of its
2020- * contributors may be used to endorse or promote products derived
2121- * from this software without specific prior written permission.
2222- *
2323- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2424- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2525- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2626- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2727- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2828- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2929- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3030- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3131- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3232- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3333- * POSSIBILITY OF SUCH DAMAGE.
3434- */
3535-3636-#define MD_SECT_CALL_FUNC(section, func) \
3737- __asm (".section "#section", \"ax\"\n" \
3838- " call " #func "\n" \
3939- " .previous")
4040-4141-/*
4242- * Align is after because we want the function to start at the first
4343- * address of the section, but overall we want the section to be
4444- * aligned by the align amount.
4545- */
4646-#define MD_SECTION_PROLOGUE(sect, entry_pt) \
4747- __asm ( \
4848- ".section "#sect",\"ax\",@progbits \n" \
4949- " .globl " #entry_pt " \n" \
5050- " .type " #entry_pt ",@function \n" \
5151- #entry_pt": \n" \
5252- " .align 16 \n" \
5353- " /* fall thru */ \n" \
5454- " .previous")
5555-5656-5757-#define MD_SECTION_EPILOGUE(sect) \
5858- __asm ( \
5959- ".section "#sect",\"ax\",@progbits \n" \
6060- " ret \n" \
6161- " .previous")
···11-/* $OpenBSD: SYS.h,v 1.3 2004/02/22 21:28:21 miod Exp $ */
22-33-/*-
44- * Copyright (c) 1990 The Regents of the University of California.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to Berkeley by
88- * William Jolitz.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the University of
2121- * California, Berkeley and its contributors.
2222- * 4. Neither the name of the University nor the names of its contributors
2323- * may be used to endorse or promote products derived from this software
2424- * without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2828- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2929- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3030- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3131- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3232- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3333- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3434- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3535- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636- * SUCH DAMAGE.
3737- *
3838- * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
3939- * $NetBSD: SYS.h,v 1.5 2002/06/03 18:30:32 fvdl Exp $
4040- */
4141-4242-/*
4343- * XXXfvdl change to use syscall/sysret.
4444- */
4545-4646-#include <machine/asm.h>
4747-#include <sys/syscall.h>
4848-4949-#ifdef __STDC__
5050-5151-#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall
5252-#define OSYSTRAP(x) movl $(SYS_ ## x),%eax; int $0x80
5353-#define SYSENTRY(x) \
5454- ENTRY(_thread_sys_ ## x); \
5555- .weak _C_LABEL(x); \
5656- _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x)
5757-#else
5858-5959-#define SYSTRAP(x) movl $(SYS_/**/x),%eax; movq %rcx, %r10; syscall
6060-#define OSYSTRAP(x) movl $(SYS_/**/x),%eax; int $0x80
6161-#define SYSENTRY(x) \
6262- ENTRY(_thread_sys_/**/x); \
6363- .weak _C_LABEL(x); \
6464- _C_LABEL(x) = _C_LABEL(_thread_sys_/**/x)
6565-6666-#endif
6767-6868-#define CERROR _C_LABEL(__cerror)
6969-#define CURBRK _C_LABEL(__curbrk)
7070-7171-#define _SYSCALL_NOERROR(x,y) \
7272- SYSENTRY(x); \
7373- SYSTRAP(y)
7474-7575-#define _OSYSCALL_NOERROR(x,y) \
7676- SYSENTRY(x); \
7777- OSYSTRAP(y)
7878-7979-#ifdef PIC
8080-#define _SYSCALL(x,y) \
8181- .text; _ALIGN_TEXT; \
8282- 2: mov PIC_GOT(CERROR), %rcx; \
8383- jmp *%rcx; \
8484- _SYSCALL_NOERROR(x,y); \
8585- jc 2b
8686-#define _OSYSCALL(x,y) \
8787- .text; _ALIGN_TEXT; \
8888- 2: mov PIC_GOT(CERROR), %rcx; \
8989- jmp *%rcx; \
9090- _OSYSCALL_NOERROR(x,y); \
9191- jc 2b
9292-#else
9393-#define _SYSCALL(x,y) \
9494- .text; _ALIGN_TEXT; \
9595- 2: jmp CERROR; \
9696- _SYSCALL_NOERROR(x,y); \
9797- jc 2b
9898-#define _OSYSCALL(x,y) \
9999- .text; _ALIGN_TEXT; \
100100- 2: jmp CERROR; \
101101- _OSYSCALL_NOERROR(x,y); \
102102- jc 2b
103103-#endif
104104-105105-#define SYSCALL_NOERROR(x) \
106106- _SYSCALL_NOERROR(x,x)
107107-108108-#define OSYSCALL_NOERROR(x) \
109109- _OSYSCALL_NOERROR(x,x)
110110-111111-#define SYSCALL(x) \
112112- _SYSCALL(x,x)
113113-114114-#define OSYSCALL(x) \
115115- _OSYSCALL(x,x)
116116-117117-#define PSEUDO_NOERROR(x,y) \
118118- _SYSCALL_NOERROR(x,y); \
119119- ret
120120-121121-#define PSEUDO(x,y) \
122122- _SYSCALL(x,y); \
123123- ret
124124-125125-#define RSYSCALL_NOERROR(x) \
126126- PSEUDO_NOERROR(x,x)
127127-128128-#define RSYSCALL(x) \
129129- PSEUDO(x,x)
130130-131131-#define WSYSCALL(weak,strong) \
132132- WEAK_ALIAS(weak,strong); \
133133- PSEUDO(strong,weak)
134134-135135- .globl CERROR
···11-/* $OpenBSD: _setjmp.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: _setjmp.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
33-44-/*
55- * Copyright (c) 2001 Wasabi Systems, Inc.
66- * All rights reserved.
77- *
88- * Written by Frank van der Linden for Wasabi Systems, Inc.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed for the NetBSD Project by
2121- * Wasabi Systems, Inc.
2222- * 4. The name of Wasabi Systems, Inc. may not be used to endorse
2323- * or promote products derived from this software without specific prior
2424- * written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2828- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2929- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
3030- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3131- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3232- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3333- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3434- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3535- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3636- * POSSIBILITY OF SUCH DAMAGE.
3737- */
3838-3939-4040-#include <machine/asm.h>
4141-#include <machine/setjmp.h>
4242-4343-/*
4444- * C library -- _setjmp, _longjmp
4545- *
4646- * _longjmp(a,v)
4747- * will generate a "return(v)" from the last call to
4848- * _setjmp(a)
4949- * by restoring registers from the stack.
5050- * The previous signal state is NOT restored.
5151- */
5252-5353-ENTRY(_setjmp)
5454- movq (%rsp),%r11
5555- movq %rbx,(_JB_RBX * 8)(%rdi)
5656- movq %rbp,(_JB_RBP * 8)(%rdi)
5757- movq %r12,(_JB_R12 * 8)(%rdi)
5858- movq %r13,(_JB_R13 * 8)(%rdi)
5959- movq %r14,(_JB_R14 * 8)(%rdi)
6060- movq %r15,(_JB_R15 * 8)(%rdi)
6161- movq %rsp,(_JB_RSP * 8)(%rdi)
6262- movq %r11,(_JB_PC * 8)(%rdi)
6363-6464- xorl %eax,%eax
6565- ret
6666-6767-ENTRY(_longjmp)
6868- movq (_JB_RBX * 8)(%rdi),%rbx
6969- movq (_JB_RBP * 8)(%rdi),%rbp
7070- movq (_JB_R12 * 8)(%rdi),%r12
7171- movq (_JB_R13 * 8)(%rdi),%r13
7272- movq (_JB_R14 * 8)(%rdi),%r14
7373- movq (_JB_R15 * 8)(%rdi),%r15
7474- movq (_JB_RSP * 8)(%rdi),%rsp
7575- movq (_JB_PC * 8)(%rdi),%r11
7676-7777- movl %esi,%eax
7878- testl %eax,%eax
7979- jnz 1f
8080- incl %eax
8181-1: movq %r11,0(%rsp)
8282- ret
···11-/* $OpenBSD: fpgetmask.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpgetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
33-44-/*
55- * Written by J.T. Conklin, Apr 4, 1995
66- * Public domain.
77- */
88-99-#include <machine/asm.h>
1010-1111-/*
1212- * XXX only read x87 control word here. If an application only
1313- * uses the fp* interface to manipulate FP bits, it should
1414- * always remain in sync with the SSE mxcsr register.
1515- */
1616-1717-#ifdef WEAK_ALIAS
1818-WEAK_ALIAS(fpgetmask, _fpgetmask)
1919-ENTRY(_fpgetmask)
2020-#else
2121-ENTRY(fpgetmask)
2222-#endif
2323- fnstcw -4(%rsp)
2424- movl -4(%rsp),%eax
2525- notl %eax
2626- andl $63,%eax
2727- ret
-26
lib/libc/arch/x86_64/gen/fpgetround.S
···11-/* $OpenBSD: fpgetround.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
33-44-/*
55- * Written by J.T. Conklin, Apr 4, 1995
66- * Public domain.
77- */
88-99-#include <machine/asm.h>
1010-1111-/*
1212- * XXX store only x87 state. If an application only uses the fp*
1313- * interface, this should be in sync with the SSE mxcsr register.
1414- */
1515-1616-#ifdef WEAK_ALIAS
1717-WEAK_ALIAS(fpgetround, _fpgetround)
1818-ENTRY(_fpgetround)
1919-#else
2020-ENTRY(fpgetround)
2121-#endif
2222- fnstcw -4(%rsp)
2323- movl -4(%rsp),%eax
2424- rorl $10,%eax
2525- andl $3,%eax
2626- ret
-28
lib/libc/arch/x86_64/gen/fpgetsticky.S
···11-/* $OpenBSD: fpgetsticky.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpgetsticky.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
33-44-/*
55- * Written by Frank van der Linden at Wasabi Systems for NetBSD.
66- * Public domain.
77- *
88- */
99-1010-#include <machine/asm.h>
1111-1212-/*
1313- * XXX read both the x87 and SSE status words here, and OR
1414- * them to get a complete picture of exceptions.
1515- */
1616-1717-#ifdef WEAK_ALIAS
1818-WEAK_ALIAS(fpgetsticky, _fpgetsticky)
1919-ENTRY(_fpgetsticky)
2020-#else
2121-ENTRY(fpgetsticky)
2222-#endif
2323- fnstsw -4(%rsp)
2424- stmxcsr -8(%rsp)
2525- movl -4(%rsp),%eax
2626- orl -8(%rsp),%eax
2727- andl $63,%eax
2828- ret
-42
lib/libc/arch/x86_64/gen/fpsetmask.S
···11-/* $OpenBSD: fpsetmask.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
33-44-/*
55- * Written by Frank van der Linden at Wasabi Systems for NetBSD.
66- * Public domain.
77- */
88-99-#include <machine/asm.h>
1010-1111-/*
1212- * XXX set both the x87 control word and the SSE mxcsr register.
1313- * Applications should only set exception and round flags
1414- * via the fp*() interface, otherwise the status words
1515- * will get our of sync.
1616- */
1717-1818-#ifdef WEAK_ALIAS
1919-WEAK_ALIAS(fpsetmask, _fpsetmask)
2020-ENTRY(_fpsetmask)
2121-#else
2222-ENTRY(fpsetmask)
2323-#endif
2424- fnstcw -4(%rsp)
2525- stmxcsr -8(%rsp)
2626- andl $63,%edi
2727- notl %edi
2828-2929- movl -4(%rsp),%edx
3030- movl %edx,%eax
3131- andl %edi,%edx
3232- movl %edx,-4(%rsp)
3333-3434- movl -8(%rsp),%edx
3535- roll $7,%edi
3636- andl %edi,%edx
3737- movl %edx,-8(%rsp)
3838-3939- fldcw -4(%rsp)
4040- ldmxcsr -8(%rsp)
4141- andl $63,%eax
4242- ret
-49
lib/libc/arch/x86_64/gen/fpsetround.S
···11-/* $OpenBSD: fpsetround.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
33-44-/*
55- * Written by Frank van der Linden at Wasabi Systems for NetBSD.
66- * Public domain.
77- */
88-99-#include <machine/asm.h>
1010-1111-/*
1212- * XXX set both the x87 control word and the SSE mxcsr register.
1313- * Applications should only set exception and round flags
1414- * via the fp*() interface, otherwise the status words
1515- * will get our of sync.
1616- */
1717-1818-1919-#ifdef WEAK_ALIAS
2020-WEAK_ALIAS(fpsetround, _fpsetround)
2121-ENTRY(_fpsetround)
2222-#else
2323-ENTRY(fpsetround)
2424-#endif
2525- fnstcw -4(%rsp)
2626- stmxcsr -8(%rsp)
2727-2828- andl $3,%edi
2929-3030- movl -4(%rsp),%edx
3131- rorl $10,%edx
3232- movl %edx,%eax
3333- andl $3,%eax
3434-3535- andl $~3,%edx
3636- orl %edi,%edx
3737- roll $10,%edx
3838- movl %edx,-4(%rsp)
3939-4040- movl -8(%rsp),%edx
4141- rorl $13,%edx
4242- andl $~3,%edx
4343- orl %edi,%edx
4444- roll $13,%edx
4545- movl %edx,-8(%rsp)
4646-4747- ldmxcsr -8(%rsp)
4848- fldcw -4(%rsp)
4949- ret
-43
lib/libc/arch/x86_64/gen/fpsetsticky.S
···11-/* $OpenBSD: fpsetsticky.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fpsetsticky.S,v 1.3 2002/06/12 19:17:23 fvdl Exp $ */
33-44-/*
55- * Written by Frank van der Linden at Wasabi Systems for NetBSD
66- * Public domain.
77- */
88-99-#include <machine/asm.h>
1010-1111-/*
1212- * XXX set both the x87 status word and the SSE mxcsr register.
1313- * Applications should only set exception and round flags
1414- * via the fp*() interface, otherwise the status words
1515- * will get our of sync.
1616- */
1717-1818-1919-#ifdef WEAK_ALIAS
2020-WEAK_ALIAS(fpsetsticky, _fpsetsticky)
2121-ENTRY(_fpsetsticky)
2222-#else
2323-ENTRY(fpsetsticky)
2424-#endif
2525- fnstenv -28(%rsp)
2626- stmxcsr -32(%rsp)
2727-2828- andl $63,%edi
2929-3030- movl -24(%rsp),%eax
3131- movl %eax,%edx
3232- andl $63,%eax
3333-3434- orl %edi,%edx
3535- movl %edx,-24(%rsp)
3636-3737- movl -32(%rsp),%edx
3838- orl %edi,%edx
3939- movl %edx,-32(%rsp)
4040-4141- ldmxcsr -32(%rsp)
4242- fldenv -28(%rsp)
4343- ret
-74
lib/libc/arch/x86_64/gen/frexp.c
···11-/* $OpenBSD: frexp.c,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-33-/*
44- * Copyright (c) 1992, 1993
55- * The Regents of the University of California. All rights reserved.
66- *
77- * This software was developed by the Computer Systems Engineering group
88- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
99- * contributed to Berkeley.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. Neither the name of the University nor the names of its contributors
2020- * may be used to endorse or promote products derived from this software
2121- * without specific prior written permission.
2222- *
2323- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2424- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2525- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2626- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2727- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2828- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2929- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3030- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3131- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333- * SUCH DAMAGE.
3434- */
3535-3636-#if defined(LIBC_SCCS) && !defined(lint)
3737-static char rcsid[] = "$OpenBSD: frexp.c,v 1.1 2004/01/28 01:44:45 mickey Exp $";
3838-#endif /* LIBC_SCCS and not lint */
3939-4040-#include <sys/types.h>
4141-#include <machine/ieee.h>
4242-4343-/*
4444- * Split the given value into a fraction in the range [0.5, 1.0) and
4545- * an exponent, such that frac * (2^exp) == value. If value is 0,
4646- * return 0.
4747- */
4848-double
4949-frexp(value, eptr)
5050- double value;
5151- int *eptr;
5252-{
5353- union {
5454- double v;
5555- struct ieee_double s;
5656- } u;
5757-5858- if (value) {
5959- /*
6060- * Fractions in [0.5..1.0) have an exponent of 2^-1.
6161- * Leave Inf and NaN alone, however.
6262- * WHAT ABOUT DENORMS?
6363- */
6464- u.v = value;
6565- if (u.s.dbl_exp != DBL_EXP_INFNAN) {
6666- *eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1);
6767- u.s.dbl_exp = DBL_EXP_BIAS - 1;
6868- }
6969- return (u.v);
7070- } else {
7171- *eptr = 0;
7272- return ((double)0);
7373- }
7474-}
···11-/* $OpenBSD: isinf.c,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
11+/* $OpenBSD: amd64.h,v 1.1 2004/02/27 17:36:17 deraadt Exp $ */
2233-/*
33+/*-
44 * Copyright (c) 1992, 1993
55 * The Regents of the University of California. All rights reserved.
66 *
···3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
3434+ *
3535+ * @(#)sparc.h 8.1 (Berkeley) 6/6/93
3436 */
35373636-#if defined(LIBC_SCCS) && !defined(lint)
3737-static char rcsid[] = "$OpenBSD: isinf.c,v 1.1 2004/01/28 01:44:45 mickey Exp $";
3838-#endif /* LIBC_SCCS and not lint */
3838+/*
3939+ * offset (in bytes) of the code from the entry address of a routine.
4040+ * (see asgnsamples for use and explanation.)
4141+ */
4242+#define OFFSET_OF_CODE 0
4343+#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT))
39444040-#include <sys/types.h>
4141-#include <machine/ieee.h>
4242-4343-int
4444-isinf(d)
4545- double d;
4646-{
4747- struct ieee_double *p = (struct ieee_double *)&d;
4848-4949- return (p->dbl_exp == DBL_EXP_INFNAN &&
5050- p->dbl_frach == 0 && p->dbl_fracl == 0);
5151-}
4545+enum opermodes { dummy };
4646+typedef enum opermodes operandenum;
-51
lib/libc/arch/x86_64/gen/isnan.c
···11-/* $OpenBSD: isnan.c,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-33-/*
44- * Copyright (c) 1992, 1993
55- * The Regents of the University of California. All rights reserved.
66- *
77- * This software was developed by the Computer Systems Engineering group
88- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
99- * contributed to Berkeley.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. Neither the name of the University nor the names of its contributors
2020- * may be used to endorse or promote products derived from this software
2121- * without specific prior written permission.
2222- *
2323- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2424- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2525- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2626- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2727- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2828- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2929- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3030- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3131- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333- * SUCH DAMAGE.
3434- */
3535-3636-#if defined(LIBC_SCCS) && !defined(lint)
3737-static char rcsid[] = "$OpenBSD: isnan.c,v 1.1 2004/01/28 01:44:45 mickey Exp $";
3838-#endif /* LIBC_SCCS and not lint */
3939-4040-#include <sys/types.h>
4141-#include <machine/ieee.h>
4242-4343-int
4444-isnan(d)
4545- double d;
4646-{
4747- struct ieee_double *p = (struct ieee_double *)&d;
4848-4949- return (p->dbl_exp == DBL_EXP_INFNAN &&
5050- (p->dbl_frach != 0 || p->dbl_fracl != 0));
5151-}
-57
lib/libc/arch/x86_64/gen/ldexp.c
···11-/* $OpenBSD: ldexp.c,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-33-/*-
44- * Copyright (c) 1990 The Regents of the University of California.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to Berkeley by
88- * Charles Hannum.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. Neither the name of the University nor the names of its contributors
1919- * may be used to endorse or promote products derived from this software
2020- * without specific prior written permission.
2121- *
2222- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2323- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2424- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2525- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2626- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2727- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2828- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2929- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3030- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232- * SUCH DAMAGE.
3333- */
3434-3535-#if defined(LIBC_SCCS) && !defined(lint)
3636-static char rcsid[] = "$OpenBSD: ldexp.c,v 1.1 2004/01/28 01:44:45 mickey Exp $";
3737-#endif /* LIBC_SCCS and not lint */
3838-3939-/*
4040- * ldexp(value, exp): return value * (2 ** exp).
4141- */
4242-4343-double
4444-ldexp (double value, int exp)
4545-{
4646- double temp;
4747-#if __GNUC__ >= 2
4848- __asm ("fscale"
4949- : "=t" (temp)
5050- : "0" (value), "u" ((double)exp));
5151-#else
5252- __asm ("fscale; fstp %%st(1)"
5353- : "=f" (temp)
5454- : "f" (value), "0" ((double)exp));
5555-#endif
5656- return (temp);
5757-}
-91
lib/libc/arch/x86_64/gen/modf.S
···11-/* $OpenBSD: modf.S,v 1.2 2004/02/08 17:29:39 deraadt Exp $ */
22-/* $NetBSD: modf.S,v 1.1 2001/06/19 00:25:03 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * Sean Eric Fagan.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)modf.s 5.5 (Berkeley) 3/18/91
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-/*
4545- * modf(value, iptr): return fractional part of value, and stores the
4646- * integral part into iptr (a pointer to double).
4747- *
4848- * Written by Sean Eric Fagan (sef@kithrup.COM)
4949- * Sun Mar 11 20:27:30 PST 1990
5050- */
5151-5252-/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
5353-ENTRY(modf)
5454-5555- /*
5656- * Set chop mode.
5757- */
5858- fnstcw -12(%rsp)
5959- movw -12(%rsp),%dx
6060- orw $3072,%dx
6161- movw %dx,-16(%rsp)
6262- fldcw -16(%rsp)
6363-6464- /*
6565- * Get integral part.
6666- */
6767- movsd %xmm0,-24(%rsp)
6868- fldl -24(%rsp)
6969- frndint
7070- fstpl -8(%rsp)
7171-7272- /*
7373- * Restore control word.
7474- */
7575- fldcw -12(%rsp)
7676-7777- /*
7878- * Store integral part.
7979- */
8080- movsd -8(%rsp),%xmm0
8181- movsd %xmm0,(%rdi)
8282-8383- /*
8484- * Get fractional part and return it.
8585- */
8686- fldl -24(%rsp)
8787- fsubl -8(%rsp)
8888- fstpl -8(%rsp)
8989- movsd -8(%rsp),%xmm0
9090-9191- ret
-103
lib/libc/arch/x86_64/gen/setjmp.S
···11-/* $OpenBSD: setjmp.S,v 1.2 2004/02/09 21:25:08 deraadt Exp $ */
22-/* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
33-44-/*
55- * Copyright (c) 2001 Wasabi Systems, Inc.
66- * All rights reserved.
77- *
88- * Written by Frank van der Linden for Wasabi Systems, Inc.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed for the NetBSD Project by
2121- * Wasabi Systems, Inc.
2222- * 4. The name of Wasabi Systems, Inc. may not be used to endorse
2323- * or promote products derived from this software without specific prior
2424- * written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2828- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2929- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
3030- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3131- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3232- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3333- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3434- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3535- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3636- * POSSIBILITY OF SUCH DAMAGE.
3737- */
3838-3939-4040-#include <machine/asm.h>
4141-#include <machine/setjmp.h>
4242-4343-/*
4444- * C library -- _setjmp, _longjmp
4545- *
4646- * longjmp(a,v)
4747- * will generate a "return(v)" from the last call to
4848- * setjmp(a)
4949- * by restoring registers from the stack.
5050- * The previous signal state is restored.
5151- */
5252-5353-ENTRY(setjmp)
5454- pushq %rdi
5555- xorq %rdi,%rdi
5656-#ifdef PIC
5757- call PIC_PLT(_C_LABEL(sigblock))
5858-#else
5959- call _C_LABEL(sigblock)
6060-#endif
6161- popq %rdi
6262- movq %rax,(_JB_SIGMASK * 8)(%rdi)
6363-6464- movq (%rsp),%r11
6565- movq %rbx,(_JB_RBX * 8)(%rdi)
6666- movq %rbp,(_JB_RBP * 8)(%rdi)
6767- movq %r12,(_JB_R12 * 8)(%rdi)
6868- movq %r13,(_JB_R13 * 8)(%rdi)
6969- movq %r14,(_JB_R14 * 8)(%rdi)
7070- movq %r15,(_JB_R15 * 8)(%rdi)
7171- movq %rsp,(_JB_RSP * 8)(%rdi)
7272- movq %r11,(_JB_PC * 8)(%rdi)
7373-7474-2: xorl %eax,%eax
7575- ret
7676-7777-ENTRY(longjmp)
7878- movq %rdi,%r12
7979- movl %esi,%r8d
8080-8181- movq (_JB_SIGMASK * 8)(%rdi),%rdi
8282- pushq %r8
8383-#ifdef PIC
8484- call PIC_PLT(_C_LABEL(sigsetmask))
8585-#else
8686- call _C_LABEL(sigsetmask)
8787-#endif
8888- popq %r8
8989- movq (_JB_RBX * 8)(%r12),%rbx
9090- movq (_JB_RBP * 8)(%r12),%rbp
9191- movq (_JB_R13 * 8)(%r12),%r13
9292- movq (_JB_R14 * 8)(%r12),%r14
9393- movq (_JB_R15 * 8)(%r12),%r15
9494- movq (_JB_RSP * 8)(%r12),%rsp
9595- movq (_JB_PC * 8)(%r12),%r11
9696- movq (_JB_R12 * 8)(%r12),%r12
9797-9898- movl %r8d,%eax
9999- testl %eax,%eax
100100- jnz 1f
101101- incl %eax
102102-1: movq %r11,0(%rsp)
103103- ret
-107
lib/libc/arch/x86_64/gen/sigsetjmp.S
···11-/* $OpenBSD: sigsetjmp.S,v 1.2 2004/02/09 21:25:08 deraadt Exp $ */
22-/* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
33-44-/*
55- * Copyright (c) 2001 Wasabi Systems, Inc.
66- * All rights reserved.
77- *
88- * Written by Frank van der Linden for Wasabi Systems, Inc.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed for the NetBSD Project by
2121- * Wasabi Systems, Inc.
2222- * 4. The name of Wasabi Systems, Inc. may not be used to endorse
2323- * or promote products derived from this software without specific prior
2424- * written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2828- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2929- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
3030- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3131- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3232- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3333- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3434- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3535- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3636- * POSSIBILITY OF SUCH DAMAGE.
3737- */
3838-3939-4040-#include <machine/asm.h>
4141-#include <machine/setjmp.h>
4242-4343-/*
4444- * C library -- _setjmp, _longjmp
4545- *
4646- * longjmp(a,v)
4747- * will generate a "return(v)" from the last call to
4848- * setjmp(a)
4949- * by restoring registers from the stack.
5050- * The previous signal state is restored.
5151- */
5252-5353-ENTRY(sigsetjmp)
5454- movl %esi,(_JB_SIGFLAG * 8)(%rdi)
5555- testl %esi,%esi
5656- jz 2f
5757-5858- pushq %rdi
5959- xorq %rdi,%rdi
6060-#ifdef PIC
6161- call PIC_PLT(_C_LABEL(sigblock))
6262-#else
6363- call _C_LABEL(sigblock)
6464-#endif
6565- popq %rdi
6666- movq %rax,(_JB_SIGMASK * 8)(%rdi)
6767-6868-2: movq (%rsp),%r11
6969- movq %rbx,(_JB_RBX * 8)(%rdi)
7070- movq %rbp,(_JB_RBP * 8)(%rdi)
7171- movq %r12,(_JB_R12 * 8)(%rdi)
7272- movq %r13,(_JB_R13 * 8)(%rdi)
7373- movq %r14,(_JB_R14 * 8)(%rdi)
7474- movq %r15,(_JB_R15 * 8)(%rdi)
7575- movq %rsp,(_JB_RSP * 8)(%rdi)
7676- movq %r11,(_JB_PC * 8)(%rdi)
7777-7878-2: xorl %eax,%eax
7979- ret
8080-8181-ENTRY(siglongjmp)
8282- movq %rdi,%r12
8383- pushq %rsi
8484- cmpl $0, (_JB_SIGFLAG * 8)(%rdi)
8585- jz 2f
8686-8787- movq (_JB_SIGMASK * 8)(%rdi),%rdi
8888-#ifdef PIC
8989- call PIC_PLT(_C_LABEL(sigsetmask))
9090-#else
9191- call _C_LABEL(sigsetmask)
9292-#endif
9393-2: popq %rax
9494- movq (_JB_RBX * 8)(%r12),%rbx
9595- movq (_JB_RBP * 8)(%r12),%rbp
9696- movq (_JB_R13 * 8)(%r12),%r13
9797- movq (_JB_R14 * 8)(%r12),%r14
9898- movq (_JB_R15 * 8)(%r12),%r15
9999- movq (_JB_RSP * 8)(%r12),%rsp
100100- movq (_JB_PC * 8)(%r12),%r11
101101- movq (_JB_R12 * 8)(%r12),%r12
102102-103103- testl %eax,%eax
104104- jnz 1f
105105- incl %eax
106106-1: movq %r11,0(%rsp)
107107- ret
···11-/* $OpenBSD: ffs.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/*
33- * Written by J.T. Conklin <jtc@netbsd.org>.
44- * Public domain.
55- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
66- */
77-88-#include <machine/asm.h>
99-1010-ENTRY(ffs)
1111- bsfl %edi,%eax
1212- jz L1 /* ZF is set if all bits are 0 */
1313- incl %eax /* bits numbered from 1, not 0 */
1414- ret
1515-1616- _ALIGN_TEXT
1717-L1: xorl %eax,%eax /* clear result */
1818- ret
-18
lib/libc/arch/x86_64/string/strlen.S
···11-/* $OpenBSD: strlen.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/*
33- * Written by J.T. Conklin <jtc@netbsd.org>.
44- * Public domain.
55- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
66- */
77-88-#include <machine/asm.h>
99-1010-ENTRY(strlen)
1111- cld /* set search forward */
1212- xorl %eax,%eax /* set search for null terminator */
1313- movq $-1,%rcx /* set search for lots of characters */
1414- repne /* search! */
1515- scasb
1616- notq %rcx /* get length by taking complement */
1717- leaq -1(%rcx),%rax /* and subtracting one */
1818- ret
-67
lib/libc/arch/x86_64/sys/Ovfork.S
···11-/* $OpenBSD: Ovfork.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: Ovfork.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-/*
4747- * pid = vfork();
4848- *
4949- * %edx == 0 in parent process, %edx == 1 in child process.
5050- * %eax == pid of child in parent, %eax == pid of parent in child.
5151- *
5252- */
5353-SYSENTRY(vfork)
5454- popq %r9 /* my rta into r9 */
5555- SYSTRAP(vfork)
5656- jc err
5757- decl %edx
5858- andl %edx,%eax
5959- jmp *%r9
6060-err:
6161- pushq %r9
6262-#ifdef PIC
6363- movq PIC_GOT(CERROR), %rcx
6464- jmp *%rcx
6565-#else
6666- jmp CERROR
6767-#endif
-89
lib/libc/arch/x86_64/sys/brk.S
···11-/* $OpenBSD: brk.S,v 1.2 2004/02/10 00:22:51 drahn Exp $ */
22-/* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)brk.s 5.2 (Berkeley) 12/17/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646- .globl _end
4747- .globl _C_LABEL(__minbrk)
4848- .globl _C_LABEL(minbrk)
4949- .globl __curbrk
5050-5151-#ifdef WEAK_ALIAS
5252-WEAK_ALIAS(brk, _brk)
5353-#endif
5454-5555- .data
5656-_C_LABEL(minbrk):
5757-_C_LABEL(__minbrk):
5858- .quad _end
5959- .text
6060-6161-SYSENTRY(_brk)
6262-#ifdef PIC
6363- movq PIC_GOT(_C_LABEL(__minbrk)),%rdx
6464- cmpq %rdi,(%rdx)
6565- jb 1f
6666- movq (%rdx),%rdi
6767-1:
6868- SYSTRAP(break)
6969- jc err
7070- movq PIC_GOT(__curbrk),%rdx # set up GOT addressing
7171- movq %rdi,(%rdx)
7272- xorl %eax,%eax
7373- ret
7474-err:
7575- movq PIC_GOT(CERROR),%rdx
7676- jmp *%rdx
7777-#else
7878- cmpq %rdi,_C_LABEL(__minbrk)(%rip)
7979- jb 1f
8080- movq _C_LABEL(__minbrk)(%rip),%rdi
8181-1:
8282- SYSTRAP(break)
8383- jc err
8484- movq %rdi,__curbrk(%rip)
8585- xorl %eax,%eax
8686- ret
8787-err:
8888- jmp CERROR
8989-#endif
-56
lib/libc/arch/x86_64/sys/cerror.S
···11-/* $OpenBSD: cerror.S,v 1.3 2004/02/18 16:51:21 miod Exp $ */
22-/* $NetBSD: cerror.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646- .globl _C_LABEL(errno)
4747-4848-_ENTRY(CERROR)
4949-#ifdef PIC
5050- movq PIC_GOT(_C_LABEL(errno)), %rcx
5151- movl %eax, (%rcx)
5252-#else
5353- movl %eax, _C_LABEL(errno)(%rip)
5454-#endif /* PIC */
5555- movq $-1,%rax
5656- ret
-57
lib/libc/arch/x86_64/sys/exect.S
···11-/* $OpenBSD: exect.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: exect.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)exect.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-#include <machine/psl.h>
4646-4747-SYSENTRY(exect)
4848- pushfq
4949- orb $(PSL_T>>8),1(%rsp)
5050- popfq
5151- SYSTRAP(execve)
5252-#ifdef PIC
5353- movq PIC_GOT(CERROR), %rcx
5454- jmp *%rcx
5555-#else
5656- jmp CERROR
5757-#endif
-49
lib/libc/arch/x86_64/sys/fork.S
···11-/* $OpenBSD: fork.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: fork.S,v 1.2 2003/02/13 02:50:51 nathanw Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)fork.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-SYSCALL(fork)
4747- decl %edx /* from 1 to 0 in child, 0 to -1 in parent */
4848- andl %edx,%eax
4949- ret /* pid = fork(); */
-48
lib/libc/arch/x86_64/sys/rfork.S
···11-/* $OpenBSD: rfork.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-33-/*-
44- * Copyright (c) 1990 The Regents of the University of California.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to Berkeley by
88- * William Jolitz.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the University of
2121- * California, Berkeley and its contributors.
2222- * 4. Neither the name of the University nor the names of its contributors
2323- * may be used to endorse or promote products derived from this software
2424- * without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2828- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2929- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3030- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3131- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3232- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3333- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3434- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3535- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636- * SUCH DAMAGE.
3737- *
3838- * from: @(#)fork.s 5.1 (Berkeley) 4/23/90
3939- */
4040-4141-#include <machine/asm.h>
4242-4343-#include "SYS.h"
4444-4545-SYSCALL(rfork)
4646- decl %edx /* from 1 to 0 in child, 0 to -1 in parent */
4747- andl %edx,%eax
4848- ret /* pid = rfork(); */
-82
lib/libc/arch/x86_64/sys/sbrk.S
···11-/* $OpenBSD: sbrk.S,v 1.2 2004/02/10 00:22:51 drahn Exp $ */
22-/* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646- .globl _end
4747- .globl __curbrk
4848-4949-#ifdef WEAK_ALIAS
5050-WEAK_ALIAS(sbrk, _sbrk)
5151-#endif
5252-5353- .data
5454-__curbrk: .quad _end
5555- .text
5656-5757-SYSENTRY(_sbrk)
5858-#ifdef PIC
5959- movq PIC_GOT(__curbrk),%rdx
6060- movq (%rdx),%rax
6161- addq %rax,%rdi
6262- SYSTRAP(break)
6363- jc err
6464- movq PIC_GOT(__curbrk),%rdx
6565- movq (%rdx),%rax
6666- movq %rdi,(%rdx)
6767- ret
6868-err:
6969- mov PIC_GOT(CERROR),%rdx
7070- jmp *%rdx
7171-#else
7272- movq __curbrk(%rip),%rax
7373- movq %rdi,%rsi
7474- addq %rax,%rdi
7575- SYSTRAP(break)
7676- jc err
7777- movq __curbrk(%rip),%rax
7878- addq %rsi,__curbrk(%rip)
7979- ret
8080-err:
8181- jmp CERROR
8282-#endif
-49
lib/libc/arch/x86_64/sys/sigpending.S
···11-/* $OpenBSD: sigpending.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: sigpending.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-SYSCALL(sigpending)
4747- movl %eax,(%rdi) # store old mask
4848- xorl %eax,%eax
4949- ret
-66
lib/libc/arch/x86_64/sys/sigprocmask.S
···11-/* $OpenBSD: sigprocmask.S,v 1.2 2004/02/09 21:27:21 deraadt Exp $ */
22-/* $NetBSD: sigprocmask.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-SYSENTRY(sigprocmask)
4747- testq %rsi,%rsi # check new sigset pointer
4848- jnz 1f # if not null, indirect
4949- movl $1,%edi # SIG_BLOCK
5050- jmp 2f
5151-1: movl (%rsi),%esi # fetch indirect ...
5252-2: SYSTRAP(sigprocmask)
5353- jc err
5454- testq %rdx,%rdx # test if old mask requested
5555- jz out
5656- movl %eax,(%rdx) # store old mask
5757-out:
5858- xorl %eax,%eax
5959- ret
6060-err:
6161-#ifdef PIC
6262- movq PIC_GOT(CERROR), %rcx
6363- jmp *%rcx
6464-#else
6565- jmp CERROR
6666-#endif
-60
lib/libc/arch/x86_64/sys/sigreturn.S
···11-/* $OpenBSD: sigreturn.S,v 1.2 2004/02/22 21:28:22 miod Exp $ */
22-/* $NetBSD: __sigreturn14.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90"
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-/*
4747- * We must preserve the state of the registers as the user has set them up.
4848- */
4949-#if 0 /* XXXfvdl fix later, but this one is really low priority */
5050-#ifdef GPROF
5151-#undef ENTRY
5252-#define MCOUNT_SYMBOL __mcount
5353-#define ENTRY(x) \
5454- .globl _/**/x; _ALIGN_TEXT; _/**/x: pusha ; \
5555- .data; 1:; .long 0; .text; movl $1b,%eax; call MCOUNT_SYMBOL; popa ; nop
5656-#endif /* GPROF */
5757-#endif
5858-5959-OSYSCALL(sigreturn)
6060- ret
-58
lib/libc/arch/x86_64/sys/sigsuspend.S
···11-/* $OpenBSD: sigsuspend.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
22-/* $NetBSD: sigsuspend.S,v 1.1 2001/06/19 00:25:07 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-SYSENTRY(sigsuspend)
4747- movl (%rdi),%edi # indirect to mask arg
4848- SYSTRAP(sigsuspend)
4949- jc err
5050- xorl %eax,%eax # shouldn t happen
5151- ret
5252-err:
5353-#ifdef PIC
5454- movq PIC_GOT(CERROR), %rcx
5555- jmp *%rcx
5656-#else
5757- jmp CERROR
5858-#endif
-58
lib/libc/arch/x86_64/sys/syscall.S
···11-/* $OpenBSD: syscall.S,v 1.2 2004/02/11 07:09:22 deraadt Exp $ */
22-/* $NetBSD: syscall.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */
33-44-/*-
55- * Copyright (c) 1990 The Regents of the University of California.
66- * All rights reserved.
77- *
88- * This code is derived from software contributed to Berkeley by
99- * William Jolitz.
1010- *
1111- * Redistribution and use in source and binary forms, with or without
1212- * modification, are permitted provided that the following conditions
1313- * are met:
1414- * 1. Redistributions of source code must retain the above copyright
1515- * notice, this list of conditions and the following disclaimer.
1616- * 2. Redistributions in binary form must reproduce the above copyright
1717- * notice, this list of conditions and the following disclaimer in the
1818- * documentation and/or other materials provided with the distribution.
1919- * 3. All advertising materials mentioning features or use of this software
2020- * must display the following acknowledgement:
2121- * This product includes software developed by the University of
2222- * California, Berkeley and its contributors.
2323- * 4. Neither the name of the University nor the names of its contributors
2424- * may be used to endorse or promote products derived from this software
2525- * without specific prior written permission.
2626- *
2727- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2828- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2929- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3030- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3131- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3232- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3333- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3434- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3535- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737- * SUCH DAMAGE.
3838- *
3939- * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90
4040- */
4141-4242-#include <machine/asm.h>
4343-4444-#include "SYS.h"
4545-4646-SYSENTRY(syscall)
4747- movq $0,%rax
4848- movq %rcx,%r10
4949- syscall
5050- jc err
5151- ret
5252-err:
5353-#ifdef PIC
5454- movq PIC_GOT(CERROR), %rcx
5555- jmp *%rcx
5656-#else
5757- jmp CERROR
5858-#endif
+209
lib/libkvm/kvm_amd64.c
···11+/* $OpenBSD: kvm_amd64.c,v 1.1 2004/02/27 17:36:13 deraadt Exp $ */
22+/* $NetBSD: kvm_x86_64.c,v 1.3 2002/06/05 22:01:55 fvdl Exp $ */
33+44+/*-
55+ * Copyright (c) 1989, 1992, 1993
66+ * The Regents of the University of California. All rights reserved.
77+ *
88+ * This code is derived from software developed by the Computer Systems
99+ * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
1010+ * BG 91-66 and contributed to Berkeley.
1111+ *
1212+ * Redistribution and use in source and binary forms, with or without
1313+ * modification, are permitted provided that the following conditions
1414+ * are met:
1515+ * 1. Redistributions of source code must retain the above copyright
1616+ * notice, this list of conditions and the following disclaimer.
1717+ * 2. Redistributions in binary form must reproduce the above copyright
1818+ * notice, this list of conditions and the following disclaimer in the
1919+ * documentation and/or other materials provided with the distribution.
2020+ * 3. All advertising materials mentioning features or use of this software
2121+ * must display the following acknowledgement:
2222+ * This product includes software developed by the University of
2323+ * California, Berkeley and its contributors.
2424+ * 4. Neither the name of the University nor the names of its contributors
2525+ * may be used to endorse or promote products derived from this software
2626+ * without specific prior written permission.
2727+ *
2828+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2929+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3030+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3131+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3232+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3333+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3434+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3535+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3636+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3737+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3838+ * SUCH DAMAGE.
3939+ */
4040+4141+#include <sys/cdefs.h>
4242+4343+/*
4444+ * x86-64 machine dependent routines for kvm.
4545+ */
4646+4747+#include <sys/param.h>
4848+#include <sys/user.h>
4949+#include <sys/proc.h>
5050+#include <sys/stat.h>
5151+#include <sys/kcore.h>
5252+#include <machine/kcore.h>
5353+#include <stdlib.h>
5454+#include <unistd.h>
5555+#include <nlist.h>
5656+#include <kvm.h>
5757+5858+#include <uvm/uvm_extern.h>
5959+6060+#include <limits.h>
6161+#include <db.h>
6262+6363+#include "kvm_private.h"
6464+6565+#include <machine/pmap.h>
6666+#include <machine/pte.h>
6767+#include <machine/vmparam.h>
6868+6969+void
7070+_kvm_freevtop(kd)
7171+ kvm_t *kd;
7272+{
7373+7474+ /* Not actually used for anything right now, but safe. */
7575+ if (kd->vmst != 0)
7676+ free(kd->vmst);
7777+}
7878+7979+/*ARGSUSED*/
8080+int
8181+_kvm_initvtop(kd)
8282+ kvm_t *kd;
8383+{
8484+8585+ return (0);
8686+}
8787+8888+/*
8989+ * Translate a kernel virtual address to a physical address.
9090+ */
9191+int
9292+_kvm_kvatop(kd, va, pa)
9393+ kvm_t *kd;
9494+ u_long va;
9595+ u_long *pa;
9696+{
9797+ cpu_kcore_hdr_t *cpu_kh;
9898+ u_long page_off;
9999+ pd_entry_t pde;
100100+ pt_entry_t pte;
101101+ paddr_t pde_pa, pte_pa;
102102+103103+ if (ISALIVE(kd)) {
104104+ _kvm_err(kd, 0, "vatop called in live kernel!");
105105+ return (0);
106106+ }
107107+108108+ cpu_kh = kd->cpu_data;
109109+ page_off = va & PGOFSET;
110110+111111+ /*
112112+ * Find and read all entries to get to the pa.
113113+ */
114114+115115+ /*
116116+ * Level 4.
117117+ */
118118+ pde_pa = cpu_kh->ptdpaddr + (pl4_i(va) * sizeof(pd_entry_t));
119119+ if (pread(kd->pmfd, (void *)&pde, sizeof(pde),
120120+ _kvm_pa2off(kd, pde_pa)) != sizeof(pde)) {
121121+ _kvm_syserr(kd, 0, "could not read PT level 4 entry");
122122+ goto lose;
123123+ }
124124+ if ((pde & PG_V) == 0) {
125125+ _kvm_err(kd, 0, "invalid translation (invalid level 4 PDE)");
126126+ goto lose;
127127+ }
128128+129129+ /*
130130+ * Level 3.
131131+ */
132132+ pde_pa = (pde_pa + PG_FRAME) + (pl3_i(va) * sizeof(pd_entry_t));
133133+ if (pread(kd->pmfd, (void *)&pde, sizeof(pde),
134134+ _kvm_pa2off(kd, pde_pa)) != sizeof(pde)) {
135135+ _kvm_syserr(kd, 0, "could not read PT level 3 entry");
136136+ goto lose;
137137+ }
138138+ if ((pde & PG_V) == 0) {
139139+ _kvm_err(kd, 0, "invalid translation (invalid level 3 PDE)");
140140+ goto lose;
141141+ }
142142+143143+ /*
144144+ * Level 2.
145145+ */
146146+ pde_pa = (pde_pa & PG_FRAME) + (pl2_i(va) * sizeof(pd_entry_t));
147147+ if (pread(kd->pmfd, (void *)&pde, sizeof(pde),
148148+ _kvm_pa2off(kd, pde_pa)) != sizeof(pde)) {
149149+ _kvm_syserr(kd, 0, "could not read PT level 2 entry");
150150+ goto lose;
151151+ }
152152+ if ((pde & PG_V) == 0) {
153153+ _kvm_err(kd, 0, "invalid translation (invalid level 2 PDE)");
154154+ goto lose;
155155+ }
156156+157157+158158+ /*
159159+ * Level 1.
160160+ */
161161+ pte_pa = (pde_pa & PG_FRAME) + (pl1_i(va) * sizeof(pt_entry_t));
162162+ if (pread(kd->pmfd, (void *) &pte, sizeof(pte),
163163+ _kvm_pa2off(kd, pte_pa)) != sizeof(pte)) {
164164+ _kvm_syserr(kd, 0, "could not read PTE");
165165+ goto lose;
166166+ }
167167+ /*
168168+ * Validate the PTE and return the physical address.
169169+ */
170170+ if ((pte & PG_V) == 0) {
171171+ _kvm_err(kd, 0, "invalid translation (invalid PTE)");
172172+ goto lose;
173173+ }
174174+ *pa = (pte & PG_FRAME) + page_off;
175175+ return (int)(NBPG - page_off);
176176+177177+ lose:
178178+ *pa = (u_long)~0L;
179179+ return (0);
180180+}
181181+182182+/*
183183+ * Translate a physical address to a file-offset in the crash dump.
184184+ */
185185+off_t
186186+_kvm_pa2off(kd, pa)
187187+ kvm_t *kd;
188188+ u_long pa;
189189+{
190190+ cpu_kcore_hdr_t *cpu_kh;
191191+ phys_ram_seg_t *ramsegs;
192192+ off_t off;
193193+ int i;
194194+195195+ cpu_kh = kd->cpu_data;
196196+ ramsegs = (void *)((char *)(void *)cpu_kh + ALIGN(sizeof *cpu_kh));
197197+198198+ off = 0;
199199+ for (i = 0; i < cpu_kh->nmemsegs; i++) {
200200+ if (pa >= ramsegs[i].start &&
201201+ (pa - ramsegs[i].start) < ramsegs[i].size) {
202202+ off += (pa - ramsegs[i].start);
203203+ break;
204204+ }
205205+ off += ramsegs[i].size;
206206+ }
207207+208208+ return (kd->dump_off + off);
209209+}
···11-/* $OpenBSD: _atomic_lock.c,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */
22-33-/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
44-55-/*
66- * Atomic lock for amd64 -- taken from i386 code.
77- */
88-99-#include "spinlock.h"
1010-1111-int
1212-_atomic_lock(volatile _spinlock_lock_t *lock)
1313-{
1414- _spinlock_lock_t old;
1515-1616- /*
1717- * Use the eXCHanGe instruction to swap the lock value with
1818- * a local variable containing the locked state.
1919- */
2020- old = _SPINLOCK_LOCKED;
2121- __asm__("xchg %0,%1"
2222- : "=r" (old), "=m" (*lock)
2323- : "0" (old), "1" (*lock));
2424-2525- return (old != _SPINLOCK_UNLOCKED);
2626-}
-108
lib/libpthread/arch/x86_64/uthread_machdep.c
···11-/* $OpenBSD: uthread_machdep.c,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2004 Theo de Raadt
55- *
66- * Permission to use, copy, modify, and distribute this software for any
77- * purpose with or without fee is hereby granted, provided that the above
88- * copyright notice and this permission notice appear in all copies.
99- *
1010- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1111- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1212- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1313- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1414- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1515- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1616- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1717- */
1818-1919-2020-#include <machine/param.h>
2121-#include <pthread.h>
2222-#include "pthread_private.h"
2323-2424-struct frame {
2525- long fr_gs;
2626- long fr_fs;
2727- long fr_es;
2828- long fr_ds;
2929-3030- long flag;
3131- long fr_r15;
3232- long fr_r14;
3333- long fr_r13;
3434- long fr_r12;
3535-3636- long fr_r11;
3737- long fr_r10;
3838- long fr_r9;
3939- long fr_r8;
4040-4141- long fr_rdi;
4242- long fr_rsi;
4343- long fr_rbp;
4444-4545- long fr_rbx;
4646- long fr_rdx;
4747- long fr_rcx;
4848- long fr_rax;
4949-5050- long fr_rip;
5151- int fr_cs; /* XXX unreachable? */
5252- int pad;
5353-};
5454-5555-#define copyreg(reg, lval) \
5656- __asm__("mov %%" #reg ", %0" : "=g"(lval))
5757-5858-/*
5959- * Given a stack and an entry function, initialise a state
6060- * structure that can be later switched to.
6161- */
6262-void
6363-_thread_machdep_init(struct _machdep_state* statep, void *base, int len,
6464- void (*entry)(void))
6565-{
6666- struct frame *f;
6767- int foo;
6868-6969- /* Locate the initial frame, aligned at the top of the stack */
7070- f = (struct frame *)(((long)base + len - sizeof *f) & ~ALIGNBYTES);
7171-7272- copyreg(cs, foo);
7373- f->fr_cs = foo;
7474- copyreg(ds, foo);
7575- f->fr_ds = foo;
7676- copyreg(es, foo);
7777- f->fr_es = foo;
7878- copyreg(fs, foo);
7979- f->fr_fs = foo;
8080- copyreg(gs, foo);
8181- f->fr_gs = foo;
8282-8383- f->fr_rbp = (long)-1;
8484- f->fr_rip = (long)entry;
8585-8686- statep->rsp = (long)f;
8787-8888- _thread_machdep_save_float_state(statep);
8989-}
9090-9191-#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr))
9292-#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr))
9393-#define fwait() __asm("fwait")
9494-#define fninit() __asm("fninit")
9595-9696-void
9797-_thread_machdep_save_float_state(struct _machdep_state *ms)
9898-{
9999- fxsave(&ms->fpreg);
100100- fninit();
101101- fwait();
102102-}
103103-104104-void
105105-_thread_machdep_restore_float_state(struct _machdep_state *ms)
106106-{
107107- fxrstor(&ms->fpreg);
108108-}
-26
lib/libpthread/arch/x86_64/uthread_machdep.h
···11-/* $OpenBSD: uthread_machdep.h,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2004 Theo de Raadt
55- *
66- * Permission to use, copy, modify, and distribute this software for any
77- * purpose with or without fee is hereby granted, provided that the above
88- * copyright notice and this permission notice appear in all copies.
99- *
1010- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1111- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1212- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1313- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1414- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1515- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1616- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1717- */
1818-1919-#include <sys/types.h>
2020-#include <machine/fpu.h>
2121-2222-struct _machdep_state {
2323- long rsp;
2424- /* must be 128-bit aligned */
2525- struct savefpu fpreg __attribute__ ((aligned (16)));
2626-};
-88
lib/libpthread/arch/x86_64/uthread_machdep_asm.S
···11-/* $OpenBSD: uthread_machdep_asm.S,v 1.3 2004/02/25 04:10:53 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2004 Theo de Raadt
55- *
66- * Permission to use, copy, modify, and distribute this software for any
77- * purpose with or without fee is hereby granted, provided that the above
88- * copyright notice and this permission notice appear in all copies.
99- *
1010- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1111- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1212- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1313- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1414- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1515- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1616- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1717- */
1818-1919-#include <machine/asm.h>
2020-2121-/*
2222- * Switch stacks
2323- */
2424-2525-/* void _thread_machdep_switch(new, oldsave); */
2626-ENTRY(_thread_machdep_switch)
2727- pushq %rax
2828- pushq %rcx
2929- pushq %rdx
3030- pushq %rbx
3131-3232- pushq %rbp
3333- pushq %rsi
3434- pushq %rdi
3535-3636- pushq %r8
3737- pushq %r9
3838- pushq %r10
3939- pushq %r11
4040-4141- pushq %r12
4242- pushq %r13
4343- pushq %r14
4444- pushq %r15
4545- movq $0xdeaf12345678beaf, %r15
4646- pushq %r15
4747-4848- movl %ds,%eax
4949- pushq %rax
5050- movl %es,%eax
5151- pushq %rax
5252- movl %fs,%eax
5353- pushq %rax
5454- movl %gs,%eax
5555- pushq %rax
5656-5757- movq %rsp, 0(%rsi) /* *arg2 = %rsp */
5858- movq 0(%rdi), %rsp /* %rsp = *arg1 */
5959-6060- popq %rax
6161- movl %eax,%gs
6262- popq %rax
6363- movl %eax,%fs
6464- popq %rax
6565- movl %eax,%es
6666- popq %rax
6767- movl %eax,%ds
6868-6969- popq %r15 # flag word.
7070- popq %r15
7171- popq %r14
7272- popq %r13
7373- popq %r12
7474-7575- popq %r11
7676- popq %r10
7777- popq %r9
7878- popq %r8
7979-8080- popq %rdi
8181- popq %rsi
8282- popq %rbp
8383-8484- popq %rbx
8585- popq %rdx
8686- popq %rcx
8787- popq %rax
8888- ret
···11-/* opensslconf.h */
22-/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
33-44-/* OpenSSL was configured with the following options: */
55-#ifndef OPENSSL_DOING_MAKEDEPEND
66-77-#ifndef OPENSSL_NO_KRB5
88-# define OPENSSL_NO_KRB5
99-#endif
1010-1111-#endif /* OPENSSL_DOING_MAKEDEPEND */
1212-1313-/* The OPENSSL_NO_* macros are also defined as NO_* if the application
1414- asks for it. This is a transient feature that is provided for those
1515- who haven't had the time to do the appropriate changes in their
1616- applications. */
1717-#ifdef OPENSSL_ALGORITHM_DEFINES
1818-# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)
1919-# define NO_KRB5
2020-# endif
2121-#endif
2222-2323-/* crypto/opensslconf.h.in */
2424-2525-/* Generate 80386 code? */
2626-#undef I386_ONLY
2727-2828-#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
2929-#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
3030-#define OPENSSLDIR "/etc/ssl"
3131-#endif
3232-#endif
3333-3434-#undef OPENSSL_UNISTD
3535-#define OPENSSL_UNISTD <unistd.h>
3636-3737-#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
3838-3939-#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
4040-#define IDEA_INT unsigned int
4141-#endif
4242-4343-#if defined(HEADER_MD2_H) && !defined(MD2_INT)
4444-#define MD2_INT unsigned int
4545-#endif
4646-4747-#if defined(HEADER_RC2_H) && !defined(RC2_INT)
4848-/* I need to put in a mod for the alpha - eay */
4949-#define RC2_INT unsigned int
5050-#endif
5151-5252-#if defined(HEADER_RC4_H)
5353-#if !defined(RC4_INT)
5454-/* using int types make the structure larger but make the code faster
5555- * on most boxes I have tested - up to %20 faster. */
5656-/*
5757- * I don't know what does "most" mean, but declaring "int" is a must on:
5858- * - Intel P6 because partial register stalls are very expensive;
5959- * - elder Alpha because it lacks byte load/store instructions;
6060- */
6161-#define RC4_INT unsigned int
6262-#endif
6363-#if !defined(RC4_CHUNK)
6464-/*
6565- * This enables code handling data aligned at natural CPU word
6666- * boundary. See crypto/rc4/rc4_enc.c for further details.
6767- */
6868-#undef RC4_CHUNK
6969-#endif
7070-#endif
7171-7272-#if (defined(HEADER_DES_H) || defined(HEADER_DES_OLD_H)) && !defined(DES_LONG)
7373-/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
7474- * %20 speed up (longs are 8 bytes, int's are 4). */
7575-#ifndef DES_LONG
7676-#define DES_LONG unsigned int
7777-#endif
7878-#endif
7979-8080-#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
8181-#define CONFIG_HEADER_BN_H
8282-#undef BN_LLONG
8383-8484-/* Should we define BN_DIV2W here? */
8585-8686-/* Only one for the following should be defined */
8787-/* The prime number generation stuff may not work when
8888- * EIGHT_BIT but I don't care since I've only used this mode
8989- * for debuging the bignum libraries */
9090-#define SIXTY_FOUR_BIT_LONG
9191-#undef SIXTY_FOUR_BIT
9292-#undef THIRTY_TWO_BIT
9393-#undef SIXTEEN_BIT
9494-#undef EIGHT_BIT
9595-#endif
9696-9797-#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
9898-#define CONFIG_HEADER_RC4_LOCL_H
9999-/* if this is defined data[i] is used instead of *data, this is a %20
100100- * speedup on x86 */
101101-#undef RC4_INDEX
102102-#endif
103103-104104-#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
105105-#define CONFIG_HEADER_BF_LOCL_H
106106-#undef BF_PTR
107107-#endif /* HEADER_BF_LOCL_H */
108108-109109-#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
110110-#define CONFIG_HEADER_DES_LOCL_H
111111-#ifndef DES_DEFAULT_OPTIONS
112112-/* the following is tweaked from a config script, that is why it is a
113113- * protected undef/define */
114114-#ifndef DES_PTR
115115-#define DES_PTR
116116-#endif
117117-118118-/* This helps C compiler generate the correct code for multiple functional
119119- * units. It reduces register dependancies at the expense of 2 more
120120- * registers */
121121-#ifndef DES_RISC1
122122-#undef DES_RISC1
123123-#endif
124124-125125-#ifndef DES_RISC2
126126-#define DES_RISC2
127127-#endif
128128-129129-#if defined(DES_RISC1) && defined(DES_RISC2)
130130-YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
131131-#endif
132132-133133-/* Unroll the inner loop, this sometimes helps, sometimes hinders.
134134- * Very mucy CPU dependant */
135135-#ifndef DES_UNROLL
136136-#undef DES_UNROLL
137137-#endif
138138-139139-/* These default values were supplied by
140140- * Peter Gutman <pgut001@cs.auckland.ac.nz>
141141- * They are only used if nothing else has been defined */
142142-#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
143143-/* Special defines which change the way the code is built depending on the
144144- CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
145145- even newer MIPS CPU's, but at the moment one size fits all for
146146- optimization options. Older Sparc's work better with only UNROLL, but
147147- there's no way to tell at compile time what it is you're running on */
148148-149149-#if defined( sun ) /* Newer Sparc's */
150150-# define DES_PTR
151151-# define DES_RISC1
152152-# define DES_UNROLL
153153-#elif defined( __ultrix ) /* Older MIPS */
154154-# define DES_PTR
155155-# define DES_RISC2
156156-# define DES_UNROLL
157157-#elif defined( __osf1__ ) /* Alpha */
158158-# define DES_PTR
159159-# define DES_RISC2
160160-#elif defined ( _AIX ) /* RS6000 */
161161- /* Unknown */
162162-#elif defined( __hpux ) /* HP-PA */
163163- /* Unknown */
164164-#elif defined( __aux ) /* 68K */
165165- /* Unknown */
166166-#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
167167-# define DES_UNROLL
168168-#elif defined( __sgi ) /* Newer MIPS */
169169-# define DES_PTR
170170-# define DES_RISC2
171171-# define DES_UNROLL
172172-#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
173173-# define DES_PTR
174174-# define DES_RISC1
175175-# define DES_UNROLL
176176-#endif /* Systems-specific speed defines */
177177-#endif
178178-179179-#endif /* DES_DEFAULT_OPTIONS */
180180-#endif /* HEADER_DES_LOCL_H */
+2-2
libexec/ld.so/amd64/archdep.h
···11-/* $OpenBSD: archdep.h,v 1.1 2004/02/10 14:18:14 drahn Exp $ */
11+/* $OpenBSD: archdep.h,v 1.2 2004/02/27 17:36:15 deraadt Exp $ */
2233/*
44 * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
···31313232#define DL_MALLOC_ALIGN 8 /* Arch constraint or otherwise */
33333434-#define MACHID EM_X86_64 /* ELF e_machine ID value checked */
3434+#define MACHID EM_AMD64 /* ELF e_machine ID value checked */
35353636#define RELTYPE Elf32_Rela
3737#define RELSIZE sizeof(Elf32_Rela)
···11-/* $OpenBSD: archdep.h,v 1.1 2004/02/10 14:18:14 drahn Exp $ */
22-33-/*
44- * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
55- *
66- * Redistribution and use in source and binary forms, with or without
77- * modification, are permitted provided that the following conditions
88- * are met:
99- * 1. Redistributions of source code must retain the above copyright
1010- * notice, this list of conditions and the following disclaimer.
1111- * 2. Redistributions in binary form must reproduce the above copyright
1212- * notice, this list of conditions and the following disclaimer in the
1313- * documentation and/or other materials provided with the distribution.
1414- *
1515- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1616- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1717- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1818- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
1919- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2020- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2121- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2222- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2323- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2424- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2525- * SUCH DAMAGE.
2626- *
2727- */
2828-2929-#ifndef _X86_64_ARCHDEP_H_
3030-#define _X86_64_ARCHDEP_H_
3131-3232-#define DL_MALLOC_ALIGN 8 /* Arch constraint or otherwise */
3333-3434-#define MACHID EM_X86_64 /* ELF e_machine ID value checked */
3535-3636-#define RELTYPE Elf32_Rela
3737-#define RELSIZE sizeof(Elf32_Rela)
3838-3939-#include <sys/mman.h>
4040-#include <elf_abi.h>
4141-#include <machine/reloc.h>
4242-#include "syscall.h"
4343-#include "util.h"
4444-4545-#define RTLD_TEXT_PLT
4646-4747-static inline void *
4848-_dl_mmap(void *addr, unsigned int len, unsigned int prot,
4949- unsigned int flags, int fd, off_t offset)
5050-{
5151- return((void *)_dl__syscall((quad_t)SYS_mmap, addr, len, prot,
5252- flags, fd, 0, offset));
5353-}
5454-5555-static inline void *
5656-_dl_mquery(void *addr, unsigned int len, unsigned int prot,
5757- unsigned int flags, int fd, off_t offset)
5858-{
5959- return((void *)_dl__syscall((quad_t)SYS_mquery, addr, len, prot,
6060- flags, fd, 0, offset));
6161-}
6262-6363-6464-static inline void
6565-RELOC_REL(Elf64_Rel *r, const Elf64_Sym *s, Elf64_Addr *p, unsigned long v)
6666-{
6767- /* AMD64 is a rela architecture */
6868-}
6969-7070-static inline void
7171-RELOC_RELA(Elf64_Rela *r, const Elf64_Sym *s, Elf64_Addr *p, unsigned long v)
7272-{
7373- if (ELF64_R_TYPE(r->r_info) == R_X86_64_RELATIVE) {
7474- *p = v + r->r_addend;
7575- } else if (ELF64_R_TYPE(r->r_info) == R_X86_64_GLOB_DAT) {
7676- *p = v + s->st_value + r->r_addend;
7777- } else {
7878- _dl_printf("unknown bootstrap relocation\n");
7979- _dl_exit(6);
8080- }
8181-}
8282-8383-#define RELOC_GOT(obj, offs)
8484-8585-#define GOT_PERMS PROT_READ
8686-8787-#endif /* _X86_64_ARCHDEP_H_ */
-152
libexec/ld.so/x86_64/ldasm.S
···11-/* $OpenBSD: ldasm.S,v 1.3 2004/02/23 20:52:04 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2002,2004 Dale Rahn
55- * All rights reserved.
66- *
77- * Redistribution and use in source and binary forms, with or without
88- * modification, are permitted provided that the following conditions
99- * are met:
1010- * 1. Redistributions of source code must retain the above copyright
1111- * notice, this list of conditions and the following disclaimer.
1212- * 2. Redistributions in binary form must reproduce the above copyright
1313- * notice, this list of conditions and the following disclaimer in the
1414- * documentation and/or other materials provided with the distribution.
1515- *
1616- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1717- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1818- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1919- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
2020- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2121- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2222- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2323- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2424- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2525- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2626- * SUCH DAMAGE.
2727- *
2828- */
2929-3030-3131-#define DL_DATA_SIZE (16*8) /* 16 * sizeof(ELF_Addr) */
3232-#define DL_LOFF_OFFSET (7*8) /* index 7 */
3333-#include <sys/syscall.h>
3434-#include <machine/asm.h>
3535-3636- .text
3737- .align 4
3838- .globl _dl_start
3939- .type _dl_start,@function
4040-_dl_start:
4141- movq %rsp, %r12 # save stack pointer for _rtld
4242- pushq %rbx # save ps_strings
4343- subq $DL_DATA_SIZE, %rsp # allocate dl_data
4444-4545- leaq _DYNAMIC(%rip),%rdx # &_DYNAMIC
4646- movq %rsp, %rsi # dl_data for dl_boot_bind
4747- movq %r12, %rdi # load saved SP for dl_boot_bind
4848- call _dl_boot_bind@PLT # _dl_boot_bind(sp,dl_data,dynamicp)
4949-5050- movq %rsi, %rcx # dl_data
5151- movq DL_LOFF_OFFSET(%rsi), %rdx # loff from dl_data
5252-5353- movq (%r12), %rdi
5454- leaq 16(%r12,%rdi,8), %rsi # envp
5555- movq %r12, %rdi
5656- addq $8,%rdi # argv
5757- call _dl_boot@PLT # _dl_boot(argv,envp,loff,dl_data)
5858-5959- addq $DL_DATA_SIZE,%rsp # return dl_data
6060-6161-# popq %rbx # %rbx = ps_strings - XXXDSR
6262-# popq %rdx # %rdx = cleanup - XXXDSR
6363-# popq %rcx # %rcx = obj_main - XXXDSR
6464- movq %r12, %rsp
6565- jmp *%rax
6666-6767- .section ".text"
6868-6969-#define DL_SYSCALL(n) DL_SYSCALL2(n,n)
7070-#define DL_SYSCALL2(n,c) \
7171- .global __CONCAT(_dl_,n) ;\
7272- .type __CONCAT(_dl_,n), @function ;\
7373- .align 4 ;\
7474-__CONCAT(_dl_,n): ;\
7575- movl $(__CONCAT(SYS_,c)), %eax ;\
7676- movq %rcx, %r10 ;\
7777- syscall ;\
7878- jb 1f ;\
7979- ret
8080-8181-DL_SYSCALL(open)
8282-DL_SYSCALL(fcntl)
8383-DL_SYSCALL(fstat)
8484-DL_SYSCALL(stat)
8585-DL_SYSCALL(read)
8686-DL_SYSCALL(write)
8787-DL_SYSCALL(close)
8888-DL_SYSCALL(issetugid)
8989-DL_SYSCALL(getdirentries)
9090-DL_SYSCALL(mprotect)
9191-DL_SYSCALL(munmap)
9292-DL_SYSCALL(exit)
9393-DL_SYSCALL2(_syscall,__syscall)
9494-DL_SYSCALL2(sysctl,__sysctl)
9595-9696-1:
9797- /* error: result = -errno; - handled here. */
9898- neg %rax
9999- ret
100100-101101-102102- /* _dl_sigprocmask: does not handle NULL new set */
103103-104104- .align 4
105105- .global _dl_sigprocmask
106106- .type _dl_sigprocmask,@function
107107-_dl_sigprocmask:
108108- movq (%rsi),%rsi # fetch indirect...
109109- movl $SYS_sigprocmask, %eax
110110- movq %rcx, %r10
111111- syscall
112112- jc 1b /* error: result = -errno */
113113- testq %rdx,%rdx # test if old mask requested
114114- jz 2f
115115- movq %rax,(%rdx) # store old mask
116116- xorq %rax,%rax
117117-2: ret
118118-119119- .align 4
120120- .global _dl_bind_start
121121- .type _dl_bind_start,@function
122122-_dl_bind_start:
123123- pushfq # save registers
124124- pushq %rax
125125- pushq %rcx
126126- pushq %rdx
127127- pushq %rsi
128128- pushq %rdi
129129- pushq %r8
130130- pushq %r9
131131- pushq %r10
132132- pushq %r11
133133-134134- movq 80(%rsp), %rdi # Copy of reloff
135135- movq 88(%rsp), %rsi # Copy of obj
136136- call _dl_bind@PLT # Call the binder
137137- movq %rax,88(%rsp) # Store function to be called in obj
138138-139139- popq %r11 # restore registers
140140- popq %r10
141141- popq %r9
142142- popq %r8
143143- popq %rdi
144144- popq %rsi
145145- popq %rdx
146146- popq %rcx
147147- popq %rax
148148- popfq
149149-150150- leaq 8(%rsp),%rsp # Discard reloff, do not change eflags
151151- ret
152152-
-454
libexec/ld.so/x86_64/rtld_machine.c
···11-/* $OpenBSD: rtld_machine.c,v 1.5 2004/02/23 20:52:04 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2002,2004 Dale Rahn
55- * Copyright (c) 2001 Niklas Hallqvist
66- * Copyright (c) 2001 Artur Grabowski
77- *
88- * Redistribution and use in source and binary forms, with or without
99- * modification, are permitted provided that the following conditions
1010- * are met:
1111- * 1. Redistributions of source code must retain the above copyright
1212- * notice, this list of conditions and the following disclaimer.
1313- * 2. Redistributions in binary form must reproduce the above copyright
1414- * notice, this list of conditions and the following disclaimer in the
1515- * documentation and/or other materials provided with the distribution.
1616- *
1717- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1818- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1919- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2020- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
2121- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2222- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2323- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2424- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2525- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727- * SUCH DAMAGE.
2828- */
2929-/*-
3030- * Copyright (c) 2000 Eduardo Horvath.
3131- * Copyright (c) 1999 The NetBSD Foundation, Inc.
3232- * All rights reserved.
3333- *
3434- * This code is derived from software contributed to The NetBSD Foundation
3535- * by Paul Kranenburg.
3636- *
3737- * Redistribution and use in source and binary forms, with or without
3838- * modification, are permitted provided that the following conditions
3939- * are met:
4040- * 1. Redistributions of source code must retain the above copyright
4141- * notice, this list of conditions and the following disclaimer.
4242- * 2. Redistributions in binary form must reproduce the above copyright
4343- * notice, this list of conditions and the following disclaimer in the
4444- * documentation and/or other materials provided with the distribution.
4545- * 3. All advertising materials mentioning features or use of this software
4646- * must display the following acknowledgement:
4747- * This product includes software developed by the NetBSD
4848- * Foundation, Inc. and its contributors.
4949- * 4. Neither the name of The NetBSD Foundation nor the names of its
5050- * contributors may be used to endorse or promote products derived
5151- * from this software without specific prior written permission.
5252- *
5353- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
5454- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
5555- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
5656- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
5757- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5858- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5959- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
6060- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
6161- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6262- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
6363- * POSSIBILITY OF SUCH DAMAGE.
6464- */
6565-6666-#define _DYN_LOADER
6767-6868-#include <sys/types.h>
6969-#include <sys/cdefs.h>
7070-#include <sys/mman.h>
7171-7272-#include <nlist.h>
7373-#include <link.h>
7474-#include <signal.h>
7575-7676-#include "syscall.h"
7777-#include "archdep.h"
7878-#include "resolve.h"
7979-8080-void
8181-_dl_bcopy(const void *src, void *dest, int size)
8282-{
8383- const unsigned char *psrc = src;
8484- unsigned char *pdest = dest;
8585- int i;
8686-8787- for (i = 0; i < size; i++)
8888- pdest[i] = psrc[i];
8989-}
9090-9191-/*
9292- * The following table holds for each relocation type:
9393- * - the width in bits of the memory location the relocation
9494- * applies to (not currently used)
9595- * - the number of bits the relocation value must be shifted to the
9696- * right (i.e. discard least significant bits) to fit into
9797- * the appropriate field in the instruction word.
9898- * - flags indicating whether
9999- * * the relocation involves a symbol
100100- * * the relocation is relative to the current position
101101- * * the relocation is for a GOT entry
102102- * * the relocation is relative to the load address
103103- *
104104- */
105105-#define _RF_S 0x80000000 /* Resolve symbol */
106106-#define _RF_A 0x40000000 /* Use addend */
107107-#define _RF_P 0x20000000 /* Location relative */
108108-#define _RF_G 0x10000000 /* GOT offset */
109109-#define _RF_B 0x08000000 /* Load address relative */
110110-#define _RF_U 0x04000000 /* Unaligned */
111111-#define _RF_E 0x02000000 /* ERROR */
112112-#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
113113-#define _RF_RS(s) ((s) & 0xff) /* right shift */
114114-static int reloc_target_flags[] = {
115115- 0, /* 0 NONE */
116116- _RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* 1 _64*/
117117- _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* 2 PC32 */
118118- _RF_G|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 3 GOT32 */
119119- _RF_E|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 4 PLT32 */
120120- _RF_S| _RF_SZ(32) | _RF_RS(0), /* 5 COPY */
121121- _RF_S| _RF_SZ(64) | _RF_RS(0), /* 6 GLOB_DAT*/
122122- _RF_S| _RF_SZ(64) | _RF_RS(0), /* 7 JUMP_SLOT*/
123123- _RF_A| _RF_B| _RF_SZ(64) | _RF_RS(0), /* 8 RELATIVE*/
124124- _RF_E, /* 9 GOTPCREL*/
125125- _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 10 32 */
126126- _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 11 32S */
127127- _RF_S|_RF_A| _RF_SZ(16) | _RF_RS(0), /* 12 16 */
128128- _RF_S|_RF_A|_RF_P| _RF_SZ(16) | _RF_RS(0), /* 13 PC16 */
129129- _RF_S|_RF_A| _RF_SZ(8) | _RF_RS(0), /* 14 8 */
130130- _RF_S|_RF_A|_RF_P| _RF_SZ(8) | _RF_RS(0), /* 15 PC8 */
131131- _RF_E, /* 16 DPTMOD64*/
132132- _RF_E, /* 17 DTPOFF64*/
133133- _RF_E, /* 18 TPOFF64 */
134134- _RF_E, /* 19 TLSGD */
135135- _RF_E, /* 20 TLSLD */
136136- _RF_E, /* 21 DTPOFF32*/
137137- _RF_E, /* 22 GOTTPOFF*/
138138- _RF_E /* 23 TPOFF32*/
139139-};
140140-141141-#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
142142-#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0)
143143-#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0)
144144-#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0)
145145-#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0)
146146-#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff)
147147-#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
148148-#define RELOC_ERROR(t) (reloc_target_flags[t] & _RF_E)
149149-150150-static long reloc_target_bitmask[] = {
151151-#define _BM(x) (x == 64? ~0 : ~(-(1UL << (x))))
152152- 0, /* 0 NONE */
153153- _BM(64), /* 1 _64*/
154154- _BM(32), /* 2 PC32 */
155155- _BM(32), /* 3 GOT32 */
156156- _BM(32), /* 4 PLT32 */
157157- _BM(0), /* 5 COPY */
158158- _BM(64), /* 6 GLOB_DAT*/
159159- _BM(64), /* 7 JUMP_SLOT*/
160160- _BM(64), /* 8 RELATIVE*/
161161- _BM(32), /* 9 GOTPCREL*/
162162- _BM(32), /* 10 32 */
163163- _BM(32), /* 11 32S */
164164- _BM(16), /* 12 16 */
165165- _BM(16), /* 13 PC16 */
166166- _BM(8), /* 14 8 */
167167- _BM(8), /* 15 PC8 */
168168- 0, /* 16 DPTMOD64*/
169169- 0, /* 17 DTPOFF64*/
170170- 0, /* 18 TPOFF64 */
171171- 0, /* 19 TLSGD */
172172- 0, /* 20 TLSLD */
173173- 0, /* 21 DTPOFF32*/
174174- 0, /* 22 GOTTPOFF*/
175175- 0 /* 23 TPOFF32*/
176176-#undef _BM
177177-};
178178-#define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t])
179179-180180-void _dl_reloc_plt(Elf_Addr *where, Elf_Addr value);
181181-182182-int
183183-_dl_md_reloc(elf_object_t *object, int rel, int relsz)
184184-{
185185- long i;
186186- long numrel;
187187- long fails = 0;
188188- Elf_Addr loff;
189189- Elf_RelA *rels;
190190- struct load_list *llist;
191191-192192- loff = object->load_offs;
193193- numrel = object->Dyn.info[relsz] / sizeof(Elf_RelA);
194194- rels = (Elf_RelA *)(object->Dyn.info[rel]);
195195- if (rels == NULL)
196196- return(0);
197197-198198- /*
199199- * unprotect some segments if we need it.
200200- */
201201- if ((rel == DT_REL || rel == DT_RELA)) {
202202- for (llist = object->load_list; llist != NULL; llist = llist->next) {
203203- if (!(llist->prot & PROT_WRITE))
204204- _dl_mprotect(llist->start, llist->size,
205205- llist->prot|PROT_WRITE);
206206- }
207207- }
208208-209209- for (i = 0; i < numrel; i++, rels++) {
210210- Elf_Addr *where, value, ooff, mask;
211211- Elf_Word type;
212212- const Elf_Sym *sym, *this;
213213- const char *symn;
214214-215215- type = ELF_R_TYPE(rels->r_info);
216216-217217- if (RELOC_ERROR(type)) {
218218- _dl_printf("relocation error %d idx %d\n", type, i);
219219- _dl_exit(20);
220220- }
221221-222222- if (type == R_TYPE(NONE))
223223- continue;
224224-225225- if (type == R_TYPE(JUMP_SLOT) && rel != DT_JMPREL)
226226- continue;
227227-228228- where = (Elf_Addr *)(rels->r_offset + loff);
229229-230230- if (RELOC_USE_ADDEND(type))
231231- value = rels->r_addend;
232232- else
233233- value = 0;
234234-235235- sym = NULL;
236236- symn = NULL;
237237- if (RELOC_RESOLVE_SYMBOL(type)) {
238238- sym = object->dyn.symtab;
239239- sym += ELF_R_SYM(rels->r_info);
240240- symn = object->dyn.strtab + sym->st_name;
241241-242242- if (sym->st_shndx != SHN_UNDEF &&
243243- ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
244244- value += loff;
245245- } else {
246246- this = NULL;
247247- ooff = _dl_find_symbol_bysym(object,
248248- ELF_R_SYM(rels->r_info), _dl_objects,
249249- &this, SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
250250- ((type == R_TYPE(JUMP_SLOT))?
251251- SYM_PLT:SYM_NOTPLT),
252252- sym->st_size);
253253- if (this == NULL) {
254254-resolve_failed:
255255- _dl_printf("%s: %s: can't resolve "
256256- "reference '%s'\n",
257257- _dl_progname, object->load_name,
258258- symn);
259259- fails++;
260260- continue;
261261- }
262262- value += (Elf_Addr)(ooff + this->st_value);
263263- }
264264- }
265265-266266- if (type == R_TYPE(JUMP_SLOT)) {
267267- _dl_reloc_plt(where, value);
268268- continue;
269269- }
270270-271271- if (type == R_TYPE(COPY)) {
272272- void *dstaddr = where;
273273- const void *srcaddr;
274274- const Elf_Sym *dstsym = sym, *srcsym = NULL;
275275- size_t size = dstsym->st_size;
276276- Elf_Addr soff;
277277-278278- soff = _dl_find_symbol(symn, object->next, &srcsym,
279279- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|
280280- ((type == R_TYPE(JUMP_SLOT)) ? SYM_PLT:SYM_NOTPLT),
281281- size, object);
282282- if (srcsym == NULL)
283283- goto resolve_failed;
284284-285285- srcaddr = (void *)(soff + srcsym->st_value);
286286- _dl_bcopy(srcaddr, dstaddr, size);
287287- continue;
288288- }
289289-290290- if (RELOC_PC_RELATIVE(type))
291291- value -= (Elf_Addr)where;
292292- if (RELOC_BASE_RELATIVE(type))
293293- value += loff;
294294-295295- mask = RELOC_VALUE_BITMASK(type);
296296- value >>= RELOC_VALUE_RIGHTSHIFT(type);
297297- value &= mask;
298298-299299- if (RELOC_UNALIGNED(type)) {
300300- /* Handle unaligned relocations. */
301301- Elf_Addr tmp = 0;
302302- char *ptr = (char *)where;
303303- int i, size = RELOC_TARGET_SIZE(type)/8;
304304-305305- /* Read it in one byte at a time. */
306306- for (i=0; i<size; i++)
307307- tmp = (tmp << 8) | ptr[i];
308308-309309- tmp &= ~mask;
310310- tmp |= value;
311311-312312- /* Write it back out. */
313313- for (i=0; i<size; i++)
314314- ptr[i] = ((tmp >> (8*i)) & 0xff);
315315- } else if (RELOC_TARGET_SIZE(type) > 32) {
316316- *where &= ~mask;
317317- *where |= value;
318318- } else {
319319- Elf32_Addr *where32 = (Elf32_Addr *)where;
320320-321321- *where32 &= ~mask;
322322- *where32 |= value;
323323- }
324324- }
325325-326326- /* reprotect the unprotected segments */
327327- if ((rel == DT_REL || rel == DT_RELA)) {
328328- for (llist = object->load_list; llist != NULL; llist = llist->next) {
329329- if (!(llist->prot & PROT_WRITE))
330330- _dl_mprotect(llist->start, llist->size,
331331- llist->prot);
332332- }
333333- }
334334-335335- return (fails);
336336-}
337337-338338-void
339339-_dl_reloc_plt(Elf_Addr *where, Elf_Addr value)
340340-{
341341- *where = value;
342342-}
343343-344344-/*
345345- * Resolve a symbol at run-time.
346346- */
347347-Elf_Addr
348348-_dl_bind(elf_object_t *object, int index)
349349-{
350350- Elf_RelA *rel;
351351- Elf_Word *addr;
352352- const Elf_Sym *sym, *this;
353353- const char *symn;
354354- Elf_Addr ooff, newval;
355355- sigset_t omask, nmask;
356356-357357- rel = (Elf_RelA *)(object->Dyn.info[DT_JMPREL]);
358358-359359- rel += index;
360360-361361- sym = object->dyn.symtab;
362362- sym += ELF_R_SYM(rel->r_info);
363363- symn = object->dyn.strtab + sym->st_name;
364364-365365- addr = (Elf_Word *)(object->load_offs + rel->r_offset);
366366- this = NULL;
367367- ooff = _dl_find_symbol(symn, _dl_objects, &this,
368368- SYM_SEARCH_ALL|SYM_WARNNOTFOUND|SYM_PLT, sym->st_size, object);
369369- if (this == NULL) {
370370- _dl_printf("lazy binding failed!\n");
371371- *((int *)0) = 0; /* XXX */
372372- }
373373-374374- newval = ooff + this->st_value + rel->r_addend;
375375-376376- /* if GOT is protected, allow the write */
377377- if (object->got_size != 0) {
378378- sigfillset(&nmask);
379379- _dl_sigprocmask(SIG_BLOCK, &nmask, &omask);
380380- _dl_mprotect((void*)object->got_start, object->got_size,
381381- PROT_READ|PROT_WRITE);
382382- }
383383-384384- _dl_reloc_plt((Elf_Addr *)addr, newval);
385385-386386- /* put the GOT back to RO */
387387- if (object->got_size != 0) {
388388- _dl_mprotect((void*)object->got_start, object->got_size,
389389- PROT_READ);
390390- _dl_sigprocmask(SIG_SETMASK, &omask, NULL);
391391- }
392392-393393- return(newval);
394394-}
395395-396396-void
397397-_dl_md_reloc_got(elf_object_t *object, int lazy)
398398-{
399399- extern void _dl_bind_start(void); /* XXX */
400400- Elf_Addr *pltgot = (Elf_Addr *)object->Dyn.info[DT_PLTGOT];
401401- int i, num;
402402- Elf_RelA *rel;
403403- Elf_Addr ooff;
404404- const Elf_Sym *this;
405405-406406- if (pltgot == NULL)
407407- return; /* it is possible to have no PLT/GOT relocations */
408408-409409- pltgot[1] = (Elf_Addr)object;
410410- pltgot[2] = (Elf_Addr)&_dl_bind_start;
411411-412412- if (object->Dyn.info[DT_PLTREL] != DT_RELA)
413413- return;
414414-415415- object->got_addr = NULL;
416416- object->got_size = 0;
417417- this = NULL;
418418- ooff = _dl_find_symbol("__got_start", object, &this,
419419- SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object);
420420- if (this != NULL)
421421- object->got_addr = ooff + this->st_value;
422422-423423- this = NULL;
424424- ooff = _dl_find_symbol("__got_end", object, &this,
425425- SYM_SEARCH_SELF|SYM_NOWARNNOTFOUND|SYM_PLT, 0, object);
426426- if (this != NULL)
427427- object->got_size = ooff + this->st_value - object->got_addr;
428428-429429- if (object->got_addr == NULL)
430430- object->got_start = NULL;
431431- else {
432432- object->got_start = ELF_TRUNC(object->got_addr, _dl_pagesz);
433433- object->got_size += object->got_addr - object->got_start;
434434- object->got_size = ELF_ROUND(object->got_size, _dl_pagesz);
435435- }
436436-437437- if (!lazy) {
438438- _dl_md_reloc(object, DT_JMPREL, DT_PLTRELSZ);
439439- } else {
440440- rel = (Elf_RelA *)(object->Dyn.info[DT_JMPREL]);
441441- num = (object->Dyn.info[DT_PLTRELSZ]);
442442- for (i = 0; i < num/sizeof(Elf_RelA); i++, rel++) {
443443- Elf_Addr *where;
444444- where = (Elf_Addr *)(rel->r_offset + object->load_offs);
445445- *where += object->load_offs;
446446- }
447447-448448- }
449449-450450- /* PLT is already RO on i386, no point in mprotecting it, just GOT */
451451- if (object->got_size != 0)
452452- _dl_mprotect((void*)object->got_start, object->got_size,
453453- PROT_READ);
454454-}
-63
libexec/ld.so/x86_64/syscall.h
···11-/* $OpenBSD: syscall.h,v 1.2 2004/02/23 20:52:05 deraadt Exp $ */
22-33-/*
44- * Copyright (c) 2001 Niklas Hallqvist
55- *
66- * Redistribution and use in source and binary forms, with or without
77- * modification, are permitted provided that the following conditions
88- * are met:
99- * 1. Redistributions of source code must retain the above copyright
1010- * notice, this list of conditions and the following disclaimer.
1111- * 2. Redistributions in binary form must reproduce the above copyright
1212- * notice, this list of conditions and the following disclaimer in the
1313- * documentation and/or other materials provided with the distribution.
1414- *
1515- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1616- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1717- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1818- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
1919- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2020- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2121- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2222- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2323- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2424- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2525- * SUCH DAMAGE.
2626- *
2727- */
2828-2929-#ifndef __DL_SYSCALL_H__
3030-#define __DL_SYSCALL_H__
3131-3232-#include <sys/syscall.h>
3333-#include <sys/stat.h>
3434-#include <sys/signal.h>
3535-3636-#ifndef _dl_MAX_ERRNO
3737-#define _dl_MAX_ERRNO 4096
3838-#endif
3939-#define _dl_check_error(__res) \
4040- ((int) __res < 0 && (int) __res >= -_dl_MAX_ERRNO)
4141-4242-int _dl_close(int);
4343-int _dl_exit(int);
4444-int _dl_issetugid(void);
4545-long _dl__syscall(quad_t, ...);
4646-int _dl_mprotect(const void *, int, int);
4747-int _dl_munmap(const void *, unsigned int);
4848-int _dl_open(const char *, unsigned int);
4949-int _dl_read(int, const char *, int);
5050-int _dl_stat(const char *, struct stat *);
5151-int _dl_fstat(int, struct stat *);
5252-int _dl_fcntl(int, int, ...);
5353-int _dl_getdirentries(int, char*, int, long *);
5454-int _dl_sigprocmask(int, const sigset_t *, sigset_t *);
5555-int _dl_sysctl(int *, u_int, void *, size_t *, void *, size_t);
5656-5757-static inline off_t
5858-_dl_lseek(int fildes, off_t offset, int whence)
5959-{
6060- return _dl__syscall((quad_t)SYS_lseek, fildes, 0, offset, whence);
6161-}
6262-6363-#endif /*__DL_SYSCALL_H__*/
···11-#include <machine/asm.h>
22-33-#if defined(LIBC_SCCS)
44- RCSID("$NetBSD: bcmp.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
55-#endif
66-77-ENTRY(bcmp)
88- xorl %eax,%eax /* clear return value */
99- cld /* set compare direction forward */
1010-1111- movq %rdx,%rcx /* compare by words */
1212- shrq $3,%rcx
1313- repe
1414- cmpsq
1515- jne L1
1616-1717- movq %rdx,%rcx /* compare remainder by bytes */
1818- andq $7,%rcx
1919- repe
2020- cmpsb
2121- je L2
2222-2323-L1: incl %eax
2424-L2: ret
-101
sys/lib/libkern/arch/x86_64/bcopy.S
···11-/*-
22- * Copyright (c) 1990 The Regents of the University of California.
33- * All rights reserved.
44- *
55- * This code is derived from locore.s.
66- *
77- * Redistribution and use in source and binary forms, with or without
88- * modification, are permitted provided that the following conditions
99- * are met:
1010- * 1. Redistributions of source code must retain the above copyright
1111- * notice, this list of conditions and the following disclaimer.
1212- * 2. Redistributions in binary form must reproduce the above copyright
1313- * notice, this list of conditions and the following disclaimer in the
1414- * documentation and/or other materials provided with the distribution.
1515- * 3. All advertising materials mentioning features or use of this software
1616- * must display the following acknowledgement:
1717- * This product includes software developed by the University of
1818- * California, Berkeley and its contributors.
1919- * 4. Neither the name of the University nor the names of its contributors
2020- * may be used to endorse or promote products derived from this software
2121- * without specific prior written permission.
2222- *
2323- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2424- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2525- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2626- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2727- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2828- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2929- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3030- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3131- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333- * SUCH DAMAGE.
3434- */
3535-3636-#include <machine/asm.h>
3737-3838-#if defined(LIBC_SCCS)
3939- RCSID("$NetBSD: bcopy.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
4040-#endif
4141-4242- /*
4343- * (ov)bcopy (src,dst,cnt)
4444- * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
4545- */
4646-4747-#ifdef MEMCOPY
4848-ENTRY(memcpy)
4949-#else
5050-#ifdef MEMMOVE
5151-ENTRY(memmove)
5252-#else
5353-#ifdef OVBCOPY
5454-ENTRY(ovbcopy)
5555-#else
5656-ENTRY(bcopy)
5757-#endif
5858-#endif
5959-#endif
6060-#if defined(MEMCOPY) || defined(MEMMOVE)
6161- movq %rdi,%r11 /* save dest */
6262-#else
6363- xchgq %rdi,%rsi
6464-#endif
6565- movq %rdx,%rcx
6666- movq %rdi,%rax
6767- subq %rsi,%rax
6868- cmpq %rcx,%rax /* overlapping? */
6969- jb 1f
7070- cld /* nope, copy forwards. */
7171- shrq $3,%rcx /* copy by words */
7272- rep
7373- movsq
7474- movq %rdx,%rcx
7575- andq $7,%rcx /* any bytes left? */
7676- rep
7777- movsb
7878-#if defined(MEMCOPY) || defined(MEMMOVE)
7979- movq %r11,%rax
8080-#endif
8181- ret
8282-1:
8383- addq %rcx,%rdi /* copy backwards. */
8484- addq %rcx,%rsi
8585- std
8686- andq $7,%rcx /* any fractional bytes? */
8787- decq %rdi
8888- decq %rsi
8989- rep
9090- movsb
9191- movq %rdx,%rcx /* copy remainder by words */
9292- shrq $3,%rcx
9393- subq $7,%rsi
9494- subq $7,%rdi
9595- rep
9696- movsq
9797-#if defined(MEMCOPY) || defined(MEMMOVE)
9898- movq %r11,%rax
9999-#endif
100100- cld
101101- ret
-52
sys/lib/libkern/arch/x86_64/byte_swap_2.S
···11-/* $NetBSD: byte_swap_2.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $ */
22-33-/*-
44- * Copyright (c) 1990 The Regents of the University of California.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to Berkeley by
88- * William Jolitz.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the University of
2121- * California, Berkeley and its contributors.
2222- * 4. Neither the name of the University nor the names of its contributors
2323- * may be used to endorse or promote products derived from this software
2424- * without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2828- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2929- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3030- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3131- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3232- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3333- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3434- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3535- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636- * SUCH DAMAGE.
3737- *
3838- * from: @(#)htons.s 5.2 (Berkeley) 12/17/90
3939- */
4040-4141-#include <machine/asm.h>
4242-#if defined(LIBC_SCCS)
4343- RCSID("$NetBSD: byte_swap_2.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
4444-#endif
4545-4646-_ENTRY(_C_LABEL(bswap16))
4747-_ENTRY(_C_LABEL(ntohs))
4848-_ENTRY(_C_LABEL(htons))
4949-_PROF_PROLOGUE
5050- movl %edi,%eax
5151- xchgb %ah,%al
5252- ret
-52
sys/lib/libkern/arch/x86_64/byte_swap_4.S
···11-/* $NetBSD: byte_swap_4.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $ */
22-33-/*-
44- * Copyright (c) 1990 The Regents of the University of California.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to Berkeley by
88- * William Jolitz.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the University of
2121- * California, Berkeley and its contributors.
2222- * 4. Neither the name of the University nor the names of its contributors
2323- * may be used to endorse or promote products derived from this software
2424- * without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2727- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2828- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2929- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3030- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3131- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3232- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3333- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3434- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3535- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636- * SUCH DAMAGE.
3737- *
3838- * from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
3939- */
4040-4141-#include <machine/asm.h>
4242-#if defined(LIBC_SCCS)
4343- RCSID("$NetBSD: byte_swap_4.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
4444-#endif
4545-4646-_ENTRY(_C_LABEL(bswap32))
4747-_ENTRY(_C_LABEL(ntohl))
4848-_ENTRY(_C_LABEL(htonl))
4949-_PROF_PROLOGUE
5050- movl %edi,%eax
5151- bswap %eax
5252- ret
-44
sys/lib/libkern/arch/x86_64/bzero.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: bzero.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
1111-#endif
1212-1313-ENTRY(bzero)
1414- movq %rsi,%rdx
1515-1616- cld /* set fill direction forward */
1717- xorq %rax,%rax /* set fill data to 0 */
1818-1919- /*
2020- * if the string is too short, it's really not worth the overhead
2121- * of aligning to word boundries, etc. So we jump to a plain
2222- * unaligned set.
2323- */
2424- cmpq $16,%rdx
2525- jb L1
2626-2727- movq %rdi,%rcx /* compute misalignment */
2828- negq %rcx
2929- andq $7,%rcx
3030- subq %rcx,%rdx
3131- rep /* zero until word aligned */
3232- stosb
3333-3434- movq %rdx,%rcx /* zero by words */
3535- shrq $3,%rcx
3636- andq $7,%rdx
3737- rep
3838- stosq
3939-4040-L1: movq %rdx,%rcx /* zero remainder by bytes */
4141- rep
4242- stosb
4343-4444- ret
-21
sys/lib/libkern/arch/x86_64/ffs.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: ffs.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
1111-#endif
1212-1313-ENTRY(ffs)
1414- bsfl %edi,%eax
1515- jz L1 /* ZF is set if all bits are 0 */
1616- incl %eax /* bits numbered from 1, not 0 */
1717- ret
1818-1919- _ALIGN_TEXT
2020-L1: xorl %eax,%eax /* clear result */
2121- ret
-29
sys/lib/libkern/arch/x86_64/index.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: index.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
1111-#endif
1212-1313-#ifdef STRCHR
1414-ENTRY(strchr)
1515-#else
1616-ENTRY(index)
1717-#endif
1818- movq %rdi,%rax
1919- movb %sil,%cl
2020-L1:
2121- movb (%rax),%dl
2222- cmpb %dl,%cl /* found char? */
2323- je L2
2424- incq %rax
2525- testb %dl,%dl /* null terminator? */
2626- jnz L1
2727- xorq %rax,%rax
2828-L2:
2929- ret
-25
sys/lib/libkern/arch/x86_64/memchr.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: memchr.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
1111-#endif
1212-1313-ENTRY(memchr)
1414- movb %sil,%al /* set character to search for */
1515- movq %rdx,%rcx /* set length of search */
1616- testq %rcx,%rcx /* test for len == 0 */
1717- jz L1
1818- cld /* set search forward */
1919- repne /* search! */
2020- scasb
2121- jne L1 /* scan failed, return null */
2222- leaq -1(%rdi),%rax /* adjust result of scan */
2323- ret
2424-L1: xorq %rax,%rax
2525- ret
-40
sys/lib/libkern/arch/x86_64/memcmp.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: memcmp.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
1111-#endif
1212-1313-ENTRY(memcmp)
1414- cld /* set compare direction forward */
1515- movq %rdx,%rcx /* compare by longs */
1616- shrq $3,%rcx
1717- repe
1818- cmpsq
1919- jne L5 /* do we match so far? */
2020-2121- movq %rdx,%rcx /* compare remainder by bytes */
2222- andq $7,%rcx
2323- repe
2424- cmpsb
2525- jne L6 /* do we match? */
2626-2727- xorl %eax,%eax /* we match, return zero */
2828- ret
2929-3030-L5: movl $8,%ecx /* We know that one of the next */
3131- subq %rcx,%rdi /* eight pairs of bytes do not */
3232- subq %rcx,%rsi /* match. */
3333- repe
3434- cmpsb
3535-L6: xorl %eax,%eax /* Perform unsigned comparison */
3636- movb -1(%rdi),%al
3737- xorl %edx,%edx
3838- movb -1(%rsi),%dl
3939- subl %edx,%eax
4040- ret
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: rindex.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $")
1111-#endif
1212-1313-#ifdef STRRCHR
1414-ENTRY(strrchr)
1515-#else
1616-ENTRY(rindex)
1717-#endif
1818- movb %sil,%cl
1919- xorq %rax,%rax /* init pointer to null */
2020-L1:
2121- movb (%rdi),%dl
2222- cmpb %dl,%cl
2323- jne L2
2424- movq %rdi,%rax
2525-L2:
2626- incq %rdi
2727- testb %dl,%dl /* null terminator??? */
2828- jnz L1
2929- ret
-62
sys/lib/libkern/arch/x86_64/scanc.S
···11-/* $NetBSD: scanc.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $ */
22-33-/*-
44- * Copyright (c) 1998 The NetBSD Foundation, Inc.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to The NetBSD Foundation
88- * by Charles M. Hannum.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the NetBSD
2121- * Foundation, Inc. and its contributors.
2222- * 4. Neither the name of The NetBSD Foundation nor the names of its
2323- * contributors may be used to endorse or promote products derived
2424- * from this software without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2727- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2828- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2929- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
3030- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3131- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3232- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3333- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3434- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3535- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3636- * POSSIBILITY OF SUCH DAMAGE.
3737- */
3838-3939-/*
4040- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
4141- */
4242-4343-#include <machine/asm.h>
4444-4545-ENTRY(scanc)
4646- movq %rdx,%r11
4747- movb %cl,%dl
4848- movl %edi,%ecx
4949- testl %ecx,%ecx
5050- jz 2f
5151- movq %r11,%rdi
5252- xorq %rax,%rax
5353- cld
5454-1:
5555- lodsb
5656- testb %dl,(%rax,%rdi)
5757- jnz 2f
5858- decl %ecx
5959- jnz 1b
6060-2:
6161- movl %ecx,%eax
6262- ret
-56
sys/lib/libkern/arch/x86_64/skpc.S
···11-/* $NetBSD: skpc.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $ */
22-33-/*-
44- * Copyright (c) 1998 The NetBSD Foundation, Inc.
55- * All rights reserved.
66- *
77- * This code is derived from software contributed to The NetBSD Foundation
88- * by Charles M. Hannum.
99- *
1010- * Redistribution and use in source and binary forms, with or without
1111- * modification, are permitted provided that the following conditions
1212- * are met:
1313- * 1. Redistributions of source code must retain the above copyright
1414- * notice, this list of conditions and the following disclaimer.
1515- * 2. Redistributions in binary form must reproduce the above copyright
1616- * notice, this list of conditions and the following disclaimer in the
1717- * documentation and/or other materials provided with the distribution.
1818- * 3. All advertising materials mentioning features or use of this software
1919- * must display the following acknowledgement:
2020- * This product includes software developed by the NetBSD
2121- * Foundation, Inc. and its contributors.
2222- * 4. Neither the name of The NetBSD Foundation nor the names of its
2323- * contributors may be used to endorse or promote products derived
2424- * from this software without specific prior written permission.
2525- *
2626- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2727- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2828- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2929- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
3030- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3131- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3232- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3333- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3434- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3535- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3636- * POSSIBILITY OF SUCH DAMAGE.
3737- */
3838-3939-/*
4040- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
4141- */
4242-4343-#include <machine/asm.h>
4444-4545-ENTRY(skpc)
4646- movl %edi,%eax
4747- movq %rsi,%rcx
4848- movq %rdx,%rdi
4949- cld
5050- repe
5151- scasb
5252- je 1f
5353- incq %rcx
5454-1:
5555- movl %ecx,%eax
5656- ret
-65
sys/lib/libkern/arch/x86_64/strcat.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: strcat.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $")
1111-#endif
1212-1313-/*
1414- * NOTE: I've unrolled the loop eight times: large enough to make a
1515- * significant difference, and small enough not to totally trash the
1616- * cache.
1717- */
1818-1919-ENTRY(strcat)
2020- movq %rdi,%r11
2121-2222- cld /* set search forward */
2323- xorl %eax,%eax /* set search for null terminator */
2424- movq $-1,%rcx /* set search for lots of characters */
2525- repne /* search! */
2626- scasb
2727-2828- decq %rdi
2929-3030-L1: movb (%rsi),%al /* unroll loop, but not too much */
3131- movb %al,(%rdi)
3232- testb %al,%al
3333- jz L2
3434- movb 1(%rsi),%al
3535- movb %al,1(%rdi)
3636- testb %al,%al
3737- jz L2
3838- movb 2(%rsi),%al
3939- movb %al,2(%rdi)
4040- testb %al,%al
4141- jz L2
4242- movb 3(%rsi),%al
4343- movb %al,3(%rdi)
4444- testb %al,%al
4545- jz L2
4646- movb 4(%rsi),%al
4747- movb %al,4(%rdi)
4848- testb %al,%al
4949- jz L2
5050- movb 5(%rsi),%al
5151- movb %al,5(%rdi)
5252- testb %al,%al
5353- jz L2
5454- movb 6(%rsi),%al
5555- movb %al,6(%rdi)
5656- testb %al,%al
5757- jz L2
5858- movb 7(%rsi),%al
5959- movb %al,7(%rdi)
6060- addq $8,%rsi
6161- addq $8,%rdi
6262- testb %al,%al
6363- jnz L1
6464-L2: movq %r11,%rax
6565- ret
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: strcmp.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $")
1111-#endif
1212-1313-/*
1414- * NOTE: I've unrolled the loop eight times: large enough to make a
1515- * significant difference, and small enough not to totally trash the
1616- * cache.
1717- */
1818-1919-ENTRY(strcmp)
2020- jmp L2 /* Jump into the loop. */
2121-2222-L1: incq %rdi
2323- incq %rsi
2424-L2: movb (%rdi),%cl
2525- testb %cl,%cl /* null terminator */
2626- jz L3
2727- cmpb %cl,(%rsi) /* chars match */
2828- jne L3
2929-3030- incq %rdi
3131- incq %rsi
3232- movb (%rdi),%cl
3333- testb %cl,%cl
3434- jz L3
3535- cmpb %cl,(%rsi)
3636- jne L3
3737-3838- incq %rdi
3939- incq %rsi
4040- movb (%rdi),%cl
4141- testb %cl,%cl
4242- jz L3
4343- cmpb %cl,(%rsi)
4444- jne L3
4545-4646- incq %rdi
4747- incq %rsi
4848- movb (%rdi),%cl
4949- testb %cl,%cl
5050- jz L3
5151- cmpb %cl,(%rsi)
5252- jne L3
5353-5454- incq %rdi
5555- incq %rsi
5656- movb (%rdi),%cl
5757- testb %cl,%cl
5858- jz L3
5959- cmpb %cl,(%rsi)
6060- jne L3
6161-6262- incq %rdi
6363- incq %rsi
6464- movb (%rdi),%cl
6565- testb %cl,%cl
6666- jz L3
6767- cmpb %cl,(%rsi)
6868- jne L3
6969-7070- incq %rdi
7171- incq %rsi
7272- movb (%rdi),%cl
7373- testb %cl,%cl
7474- jz L3
7575- cmpb %cl,(%rsi)
7676- jne L3
7777-7878- incq %rdi
7979- incq %rsi
8080- movb (%rdi),%cl
8181- testb %cl,%cl
8282- jz L3
8383- cmpb %cl,(%rsi)
8484- je L1
8585-L3: movzbl (%rdi),%eax /* unsigned comparison */
8686- movzbl (%rsi),%edx
8787- subl %edx,%eax
8888- ret
-57
sys/lib/libkern/arch/x86_64/strcpy.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: strcpy.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $")
1111-#endif
1212-1313-/*
1414- * NOTE: I've unrolled the loop eight times: large enough to make a
1515- * significant difference, and small enough not to totally trash the
1616- * cache.
1717- */
1818-1919-ENTRY(strcpy)
2020- movq %rdi,%r11
2121-2222-L1: movb (%rsi),%al /* unroll loop, but not too much */
2323- movb %al,(%rdi)
2424- testb %al,%al
2525- jz L2
2626- movb 1(%rsi),%al
2727- movb %al,1(%rdi)
2828- testb %al,%al
2929- jz L2
3030- movb 2(%rsi),%al
3131- movb %al,2(%rdi)
3232- testb %al,%al
3333- jz L2
3434- movb 3(%rsi),%al
3535- movb %al,3(%rdi)
3636- testb %al,%al
3737- jz L2
3838- movb 4(%rsi),%al
3939- movb %al,4(%rdi)
4040- testb %al,%al
4141- jz L2
4242- movb 5(%rsi),%al
4343- movb %al,5(%rdi)
4444- testb %al,%al
4545- jz L2
4646- movb 6(%rsi),%al
4747- movb %al,6(%rdi)
4848- testb %al,%al
4949- jz L2
5050- movb 7(%rsi),%al
5151- movb %al,7(%rdi)
5252- addq $8,%rsi
5353- addq $8,%rdi
5454- testb %al,%al
5555- jnz L1
5656-L2: movq %r11,%rax
5757- ret
-21
sys/lib/libkern/arch/x86_64/strlen.S
···11-/*
22- * Written by J.T. Conklin <jtc@netbsd.org>.
33- * Public domain.
44- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
55- */
66-77-#include <machine/asm.h>
88-99-#if defined(LIBC_SCCS)
1010- RCSID("$NetBSD: strlen.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $")
1111-#endif
1212-1313-ENTRY(strlen)
1414- cld /* set search forward */
1515- xorl %eax,%eax /* set search for null terminator */
1616- movq $-1,%rcx /* set search for lots of characters */
1717- repne /* search! */
1818- scasb
1919- notq %rcx /* get length by taking complement */
2020- leaq -1(%rcx),%rax /* and subtracting one */
2121- ret
···11-/* $OpenBSD: pmdb_machdep.h,v 1.1 2004/01/29 12:44:40 mickey Exp $ */
22-/*
33- * Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
44- * All rights reserved.
55- *
66- * Redistribution and use in source and binary forms, with or without
77- * modification, are permitted provided that the following conditions
88- * are met:
99- *
1010- * 1. Redistributions of source code must retain the above copyright
1111- * notice, this list of conditions and the following disclaimer.
1212- * 2. The name of the author may not be used to endorse or promote products
1313- * derived from this software without specific prior written permission.
1414- *
1515- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
1616- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
1717- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
1818- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1919- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2020- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2121- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2222- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2323- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2424- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525- */
2626-2727-#define BREAKPOINT { 0xcc }
2828-#define BREAKPOINT_LEN 1
2929-#define BREAKPOINT_DECR_PC 1
-94
usr.bin/pmdb/arch/x86_64/x86_64.c
···11-/* $OpenBSD: x86_64.c,v 1.2 2004/02/10 23:36:02 mickey Exp $ */
22-33-/*
44- * Copyright (c) 2002 Federico Schwindt <fgsch@openbsd.org>
55- * All rights reserved.
66- *
77- * Redistribution and use in source and binary forms, with or without
88- * modification, are permitted provided that the following conditions
99- * are met:
1010- *
1111- * 1. Redistributions of source code must retain the above copyright
1212- * notice, this list of conditions and the following disclaimer.
1313- * 2. The name of the author may not be used to endorse or promote products
1414- * derived from this software without specific prior written permission.
1515- *
1616- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
1717- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
1818- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
1919- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2020- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2121- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2222- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2323- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2424- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2525- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626- */
2727-2828-#include <sys/param.h>
2929-#include <sys/ptrace.h>
3030-#include <machine/reg.h>
3131-#include <machine/frame.h>
3232-#include <string.h>
3333-#include "pmdb.h"
3434-3535-/*
3636- * No frame for x86?
3737- */
3838-struct frame {
3939- long fp;
4040- long pc;
4141-};
4242-4343-static const char *md_reg_names[] = {
4444- "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11",
4545- "%r12", "%r13", "%r14", "%r15", "%rbp", "%rbx", "%rax", "%rsp",
4646- "%rip", "%rflags", "%cs", "%ss", "%ds", "%es", "%fs", "%gs",
4747-};
4848-4949-struct md_def md_def = { md_reg_names, 16, 8 };
5050-5151-void
5252-md_def_init(void)
5353-{
5454- /* no need to do anything */
5555-}
5656-5757-int
5858-md_getframe(struct pstate *ps, int frame, struct md_frame *fram)
5959-{
6060- struct frame fr;
6161- struct reg r;
6262- int count;
6363-6464- if (process_getregs(ps, &r) != 0)
6565- return (-1);
6666-6767- fr.fp = r.r_rbp;
6868- fr.pc = r.r_rip;
6969- for (count = 0; count < frame; count++) {
7070- if (process_read(ps, fr.fp, &fr, sizeof(fr)) < 0)
7171- return (-1);
7272-7373- if (fr.pc < 0x1000)
7474- return (-1);
7575- }
7676-7777- fram->pc = fr.pc;
7878- fram->fp = fr.fp;
7979-8080- return (0);
8181-}
8282-8383-int
8484-md_getregs(struct pstate *ps, reg *regs)
8585-{
8686- struct reg r;
8787-8888- if (process_getregs(ps, &r) != 0)
8989- return (-1);
9090-9191- memcpy(regs, &r, sizeof(r));
9292-9393- return (0);
9494-}