diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-11-20 21:51:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-11-20 21:51:03 +0000 |
commit | 2bf8c4b7d0f1e744374c7c7294480e337026f582 (patch) | |
tree | 5b7f9d455179238ea1abce58c350066795754cf3 /lib/libc | |
parent | f34c61c79cffdc5532b5d0920a7d4488214751e4 (diff) |
One of these optimized stubs creates some incredibly subtle damage,
causing as(1) to create a wrong nop-sled for text segment aligns.
Revert, until it is found and fixed.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/amd64/string/Makefile.inc | 9 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/bcmp.S | 20 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/bcopy.S | 1 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/bzero.S | 40 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memchr.S | 21 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memcmp.S | 36 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memcpy.S | 1 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memmove.S | 87 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memset.S | 54 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/strchr.S | 21 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/strcmp.S | 84 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/strrchr.S | 21 |
12 files changed, 4 insertions, 391 deletions
diff --git a/lib/libc/arch/amd64/string/Makefile.inc b/lib/libc/arch/amd64/string/Makefile.inc index d8fd26a9cb7..de110416a73 100644 --- a/lib/libc/arch/amd64/string/Makefile.inc +++ b/lib/libc/arch/amd64/string/Makefile.inc @@ -1,7 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.5 2014/11/20 14:33:00 reyk Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2014/11/20 21:51:02 deraadt Exp $ -SRCS+= bcmp.S ffs.S index.c memchr.S memcmp.S bcopy.S bzero.S \ - rindex.c strcat.c strcmp.S strcpy.c strcspn.c strlen.c \ +SRCS+= bcmp.c ffs.S index.c memchr.c memcmp.c bcopy.c bzero.c \ + rindex.c strcat.c strcmp.c strcpy.c strcspn.c strlen.c \ strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \ - strspn.c strstr.c swab.c memset.S strlcpy.c strlcat.c -SRCS+= memcpy.S memmove.S strchr.S strrchr.S + strspn.c strstr.c swab.c memset.c strlcpy.c strlcat.c diff --git a/lib/libc/arch/amd64/string/bcmp.S b/lib/libc/arch/amd64/string/bcmp.S deleted file mode 100644 index 3c96a90b340..00000000000 --- a/lib/libc/arch/amd64/string/bcmp.S +++ /dev/null @@ -1,20 +0,0 @@ -#include <machine/asm.h> - -ENTRY(bcmp) - xorl %eax,%eax /* clear return value */ - cld /* set compare direction forward */ - - movq %rdx,%rcx /* compare by words */ - shrq $3,%rcx - repe - cmpsq - jne L1 - - movq %rdx,%rcx /* compare remainder by bytes */ - andq $7,%rcx - repe - cmpsb - je L2 - -L1: incl %eax -L2: ret diff --git a/lib/libc/arch/amd64/string/bcopy.S b/lib/libc/arch/amd64/string/bcopy.S deleted file mode 100644 index c9361568da4..00000000000 --- a/lib/libc/arch/amd64/string/bcopy.S +++ /dev/null @@ -1 +0,0 @@ -/* This code is contained in memmove.S */ diff --git a/lib/libc/arch/amd64/string/bzero.S b/lib/libc/arch/amd64/string/bzero.S deleted file mode 100644 index 76adafc20ab..00000000000 --- a/lib/libc/arch/amd64/string/bzero.S +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(bzero) - movq %rsi,%rdx - - cld /* set fill direction forward */ - xorq %rax,%rax /* set fill data to 0 */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundaries, etc. So we jump to a plain - * unaligned set. - */ - cmpq $16,%rdx - jb L1 - - movq %rdi,%rcx /* compute misalignment */ - negq %rcx - andq $7,%rcx - subq %rcx,%rdx - rep /* zero until word aligned */ - stosb - - movq %rdx,%rcx /* zero by words */ - shrq $3,%rcx - andq $7,%rdx - rep - stosq - -L1: movq %rdx,%rcx /* zero remainder by bytes */ - rep - stosb - - ret diff --git a/lib/libc/arch/amd64/string/memchr.S b/lib/libc/arch/amd64/string/memchr.S deleted file mode 100644 index 88fa37462d2..00000000000 --- a/lib/libc/arch/amd64/string/memchr.S +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(memchr) - movb %sil,%al /* set character to search for */ - movq %rdx,%rcx /* set length of search */ - testq %rcx,%rcx /* test for len == 0 */ - jz L1 - cld /* set search forward */ - repne /* search! */ - scasb - jne L1 /* scan failed, return null */ - leaq -1(%rdi),%rax /* adjust result of scan */ - ret -L1: xorq %rax,%rax - ret diff --git a/lib/libc/arch/amd64/string/memcmp.S b/lib/libc/arch/amd64/string/memcmp.S deleted file mode 100644 index d32c66d5b93..00000000000 --- a/lib/libc/arch/amd64/string/memcmp.S +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(memcmp) - cld /* set compare direction forward */ - movq %rdx,%rcx /* compare by longs */ - shrq $3,%rcx - repe - cmpsq - jne L5 /* do we match so far? */ - - movq %rdx,%rcx /* compare remainder by bytes */ - andq $7,%rcx - repe - cmpsb - jne L6 /* do we match? */ - - xorl %eax,%eax /* we match, return zero */ - ret - -L5: movl $8,%ecx /* We know that one of the next */ - subq %rcx,%rdi /* eight pairs of bytes do not */ - subq %rcx,%rsi /* match. */ - repe - cmpsb -L6: xorl %eax,%eax /* Perform unsigned comparison */ - movb -1(%rdi),%al - xorl %edx,%edx - movb -1(%rsi),%dl - subl %edx,%eax - ret diff --git a/lib/libc/arch/amd64/string/memcpy.S b/lib/libc/arch/amd64/string/memcpy.S deleted file mode 100644 index c9361568da4..00000000000 --- a/lib/libc/arch/amd64/string/memcpy.S +++ /dev/null @@ -1 +0,0 @@ -/* This code is contained in memmove.S */ diff --git a/lib/libc/arch/amd64/string/memmove.S b/lib/libc/arch/amd64/string/memmove.S deleted file mode 100644 index 1516c743660..00000000000 --- a/lib/libc/arch/amd64/string/memmove.S +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from locore.s. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <machine/asm.h> - - /* - * memmove (dst,src,cnt) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ - -ENTRY(bcopy) - xchgq %rdi,%rsi - /* fall into memmove */ - -ENTRY(memmove) - movq %rdi,%r11 /* save dest */ - movq %rdx,%rcx - movq %rdi,%rax - subq %rsi,%rax - cmpq %rcx,%rax /* overlapping? */ - jb 1f - jmp 2f /* nope */ - -ENTRY(memcpy) - movq %rdi,%r11 /* save dest */ - movq %rdx,%rcx -2: - cld /* copy forwards. */ - shrq $3,%rcx /* copy by words */ - rep - movsq - movq %rdx,%rcx - andq $7,%rcx /* any bytes left? */ - rep - movsb - movq %r11,%rax - ret -1: - addq %rcx,%rdi /* copy backwards. */ - addq %rcx,%rsi - std - andq $7,%rcx /* any fractional bytes? */ - decq %rdi - decq %rsi - rep - movsb - movq %rdx,%rcx /* copy remainder by words */ - shrq $3,%rcx - subq $7,%rsi - subq $7,%rdi - rep - movsq - movq %r11,%rax - cld - ret diff --git a/lib/libc/arch/amd64/string/memset.S b/lib/libc/arch/amd64/string/memset.S deleted file mode 100644 index 0f6ae1064d0..00000000000 --- a/lib/libc/arch/amd64/string/memset.S +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(memset) - movq %rsi,%rax - movq %rdx,%rcx - movq %rdi,%r11 - - cld /* set fill direction forward */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundaries, etc. So we jump to a plain - * unaligned set. - */ - cmpq $0x0f,%rcx - jle L1 - - movb %al,%ah /* copy char to all bytes in word */ - movl %eax,%edx - sall $16,%eax - orl %edx,%eax - - movl %eax,%edx - salq $32,%rax - orq %rdx,%rax - - movq %rdi,%rdx /* compute misalignment */ - negq %rdx - andq $7,%rdx - movq %rcx,%r8 - subq %rdx,%r8 - - movq %rdx,%rcx /* set until word aligned */ - rep - stosb - - movq %r8,%rcx - shrq $3,%rcx /* set by words */ - rep - stosq - - movq %r8,%rcx /* set remainder by bytes */ - andq $7,%rcx -L1: rep - stosb - movq %r11,%rax - - ret diff --git a/lib/libc/arch/amd64/string/strchr.S b/lib/libc/arch/amd64/string/strchr.S deleted file mode 100644 index 058c56a5358..00000000000 --- a/lib/libc/arch/amd64/string/strchr.S +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(strchr) - movq %rdi,%rax - movb %sil,%cl -L1: - movb (%rax),%dl - cmpb %dl,%cl /* found char? */ - je L2 - incq %rax - testb %dl,%dl /* null terminator? */ - jnz L1 - xorq %rax,%rax -L2: - ret diff --git a/lib/libc/arch/amd64/string/strcmp.S b/lib/libc/arch/amd64/string/strcmp.S deleted file mode 100644 index 45c33fd60f1..00000000000 --- a/lib/libc/arch/amd64/string/strcmp.S +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -/* - * NOTE: I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strcmp) - jmp L2 /* Jump into the loop. */ - -L1: incq %rdi - incq %rsi -L2: movb (%rdi),%cl - testb %cl,%cl /* null terminator */ - jz L3 - cmpb %cl,(%rsi) /* chars match */ - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - jne L3 - - incq %rdi - incq %rsi - movb (%rdi),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%rsi) - je L1 -L3: movzbl (%rdi),%eax /* unsigned comparison */ - movzbl (%rsi),%edx - subl %edx,%eax - ret diff --git a/lib/libc/arch/amd64/string/strrchr.S b/lib/libc/arch/amd64/string/strrchr.S deleted file mode 100644 index 097b4f1f699..00000000000 --- a/lib/libc/arch/amd64/string/strrchr.S +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -ENTRY(strrchr) - movb %sil,%cl - xorq %rax,%rax /* init pointer to null */ -L1: - movb (%rdi),%dl - cmpb %dl,%cl - jne L2 - movq %rdi,%rax -L2: - incq %rdi - testb %dl,%dl /* null terminator??? */ - jnz L1 - ret |