diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2022-01-01 23:47:15 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2022-01-01 23:47:15 +0000 |
commit | 3e049e7efbe8faf255ec296f1178c1c9ad9a695f (patch) | |
tree | ae32310391fe1a97ae2944bb0fc4409ee5dff6f8 /lib | |
parent | 40cde7d140c052d443457fe79ea1818d4d673234 (diff) |
Add ENTRY_NB() macro for doing an ASM function entry without setting
the binding to global (NB == "no binding"), as clang 13 is now
warning about changing the binding from global to weak.
This first pass does amd64 and sparc64 and pulls DEFS.h out of the
per-arch directory to a common directory; others to follow
ok kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/DEFS.h | 69 | ||||
-rw-r--r-- | lib/libc/arch/amd64/DEFS.h | 69 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/bcmp.S | 2 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/bzero.S | 2 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/memmove.S | 6 | ||||
-rw-r--r-- | lib/libc/arch/amd64/sys/brk.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/amd64/sys/sbrk.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/SYS.h | 28 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/brk.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/sbrk.S | 4 |
11 files changed, 86 insertions, 110 deletions
diff --git a/lib/libc/Makefile.inc b/lib/libc/Makefile.inc index 539936a0476..03de905a23d 100644 --- a/lib/libc/Makefile.inc +++ b/lib/libc/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.29 2016/05/07 19:05:21 guenther Exp $ +# $OpenBSD: Makefile.inc,v 1.30 2022/01/01 23:47:14 guenther Exp $ # # This file contains make rules used to build libc # @@ -23,7 +23,7 @@ CFLAGS+=-DYP -I${LIBCSRCDIR}/yp .endif LLIBS= -AINC= -I${LIBCSRCDIR}/arch/${MACHINE_CPU} +AINC= -I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/arch .if defined(DESTDIR) AINC+= -nostdinc -idirafter ${DESTDIR}/usr/include .endif diff --git a/lib/libc/arch/DEFS.h b/lib/libc/arch/DEFS.h new file mode 100644 index 00000000000..97832c3ead9 --- /dev/null +++ b/lib/libc/arch/DEFS.h @@ -0,0 +1,69 @@ +/* $OpenBSD: DEFS.h,v 1.1 2022/01/01 23:47:14 guenther Exp $ */ +/* + * Copyright (c) 2015,2018,2021 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <machine/asm.h> + +/* ARM just had to be different... */ +#ifndef __arm__ +# define _FUNC_TYPE @function +#else +# define _FUNC_TYPE #function +#endif + +/* + * We define a hidden alias with the prefix "_libc_" for each global symbol + * that may be used internally. By referencing _libc_x instead of x, other + * parts of libc prevent overriding by the application and avoid unnecessary + * relocations. + */ +#define _HIDDEN(x) _libc_##x +#define _HIDDEN_ALIAS(x,y) \ + STRONG_ALIAS(_HIDDEN(x),y); \ + .hidden _HIDDEN(x) +#define _HIDDEN_FALIAS(x,y) \ + _HIDDEN_ALIAS(x,y); \ + .type _HIDDEN(x),_FUNC_TYPE + +/* + * For functions implemented in ASM that aren't syscalls. + * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names + * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names + * END_BUILTIN(x) If compiling with clang, then just END() and + * mark it .protected, else be like END_STRONG(); + * for clang builtins like memcpy + * + * If a 'BUILTIN' function needs be referenced by other ASM code, then use + * _BUILTIN(x) If compiled with clang, then just x, otherwise + * _HIDDEN(x) + * + * _END(x) Set a size on a symbol, like END(), but even for + * symbols with no matching ENTRY(). (On alpha and + * mips64, END() generates .end which requires a + * matching .ent from ENTRY()) + */ +#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); _END(_HIDDEN(x)) +#define END_WEAK(x) END_STRONG(x); .weak x + +#ifdef __clang__ +#define END_BUILTIN(x) END(x); .protected x +#define _BUILTIN(x) x +#else +#define END_BUILTIN(x) END_STRONG(x) +#define _BUILTIN(x) _HIDDEN(x) +#endif + +#define _END(x) .size x, . - x diff --git a/lib/libc/arch/amd64/DEFS.h b/lib/libc/arch/amd64/DEFS.h deleted file mode 100644 index 8e39fc58122..00000000000 --- a/lib/libc/arch/amd64/DEFS.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $OpenBSD: DEFS.h,v 1.2 2017/11/29 05:13:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $NetBSD: SYS.h,v 1.5 2002/06/03 18:30:32 fvdl Exp $ - */ - -#include <machine/asm.h> - -/* - * We define a hidden alias with the prefix "_libc_" for each global symbol - * that may be used internally. By referencing _libc_x instead of x, other - * parts of libc prevent overriding by the application and avoid unnecessary - * relocations. - */ -#define _HIDDEN(x) _libc_##x -#define _HIDDEN_ALIAS(x,y) \ - STRONG_ALIAS(_HIDDEN(x),y); \ - .hidden _HIDDEN(x) -#define _HIDDEN_FALIAS(x,y) \ - _HIDDEN_ALIAS(x,y); \ - .type _HIDDEN(x),@function - -/* - * For functions implemented in ASM that aren't syscalls. - * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names - * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names - * END_BUILTIN(x) If compiling with clang, then just END() and - * mark it .protected, else be like END_STRONG(); - * for clang builtins like memcpy - */ -#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) -#define END_WEAK(x) END_STRONG(x); .weak x - -#ifdef __clang__ -#define END_BUILTIN(x) END(x); .protected x -#else -#define END_BUILTIN(x) END_STRONG(x) -#endif diff --git a/lib/libc/arch/amd64/string/bcmp.S b/lib/libc/arch/amd64/string/bcmp.S index a9b4d463c2f..e73d1c4ebf0 100644 --- a/lib/libc/arch/amd64/string/bcmp.S +++ b/lib/libc/arch/amd64/string/bcmp.S @@ -1,6 +1,6 @@ #include "DEFS.h" -ENTRY(bcmp) +ENTRY_NB(bcmp) RETGUARD_SETUP(bcmp, r11) xorl %eax,%eax /* clear return value */ cld /* set compare direction forward */ diff --git a/lib/libc/arch/amd64/string/bzero.S b/lib/libc/arch/amd64/string/bzero.S index 5ffe391736c..6a057c20bd1 100644 --- a/lib/libc/arch/amd64/string/bzero.S +++ b/lib/libc/arch/amd64/string/bzero.S @@ -6,7 +6,7 @@ #include "DEFS.h" -ENTRY(bzero) +ENTRY_NB(bzero) RETGUARD_SETUP(bzero, r11) movq %rsi,%rdx diff --git a/lib/libc/arch/amd64/string/memmove.S b/lib/libc/arch/amd64/string/memmove.S index 9df41afb096..bb3750ee19a 100644 --- a/lib/libc/arch/amd64/string/memmove.S +++ b/lib/libc/arch/amd64/string/memmove.S @@ -40,11 +40,11 @@ * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 */ -ENTRY(bcopy) +ENTRY_NB(bcopy) xchgq %rdi,%rsi /* fall into memmove */ -NENTRY(memmove) +NENTRY_NB(memmove) RETGUARD_SETUP(memmove, r10) movq %rdi,%r11 /* save dest */ movq %rdx,%rcx @@ -55,7 +55,7 @@ NENTRY(memmove) #ifdef memcpy_in_asm jmp 2f /* nope */ -ENTRY(memcpy) +ENTRY_NB(memcpy) RETGUARD_SETUP(memmove, r10) movq %rdi,%r11 /* save dest */ movq %rdx,%rcx diff --git a/lib/libc/arch/amd64/sys/brk.S b/lib/libc/arch/amd64/sys/brk.S index 1733b0bbe98..e00f74099eb 100644 --- a/lib/libc/arch/amd64/sys/brk.S +++ b/lib/libc/arch/amd64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.11 2021/10/25 14:19:51 kettenis Exp $ */ +/* $OpenBSD: brk.S,v 1.12 2022/01/01 23:47:14 guenther Exp $ */ /* $NetBSD: brk.S,v 1.2 2002/06/03 18:30:33 fvdl Exp $ */ /*- @@ -48,7 +48,7 @@ __minbrk: END(__minbrk) .type __minbrk,@object -ENTRY(brk) +ENTRY_NB(brk) cmpq %rdi,__minbrk(%rip) jb 1f movq __minbrk(%rip),%rdi diff --git a/lib/libc/arch/amd64/sys/sbrk.S b/lib/libc/arch/amd64/sys/sbrk.S index 572675323e3..80a6a16d4e1 100644 --- a/lib/libc/arch/amd64/sys/sbrk.S +++ b/lib/libc/arch/amd64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.11 2021/10/25 14:19:51 kettenis Exp $ */ +/* $OpenBSD: sbrk.S,v 1.12 2022/01/01 23:47:14 guenther Exp $ */ /* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */ /*- @@ -53,7 +53,7 @@ __curbrk: END(__curbrk) .type __curbrk,@object -ENTRY(sbrk) +ENTRY_NB(sbrk) movq __curbrk(%rip),%rax movslq %edi,%rsi movq %rsi,%rdi diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h index 891323eb508..b0fd99d1ed8 100644 --- a/lib/libc/arch/sparc64/SYS.h +++ b/lib/libc/arch/sparc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.16 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.17 2022/01/01 23:47:14 guenther Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -37,7 +37,7 @@ * $NetBSD: SYS.h,v 1.6 2001/07/23 07:26:50 thorpej Exp $ */ -#include <machine/asm.h> +#include "DEFS.h" #include <sys/syscall.h> #include <machine/trap.h> @@ -49,30 +49,6 @@ #define __ENTRY(p,x) ENTRY(_CAT(p,x)) ; .weak x; x = _CAT(p,x) #define __ENTRY_HIDDEN(p,x) ENTRY(_CAT(p,x)) - -/* - * We define a hidden alias with the prefix "_libc_" for each global symbol - * that may be used internally. By referencing _libc_x instead of x, other - * parts of libc prevent overriding by the application and avoid unnecessary - * relocations. - */ -#define _HIDDEN(x) _libc_##x -#define _HIDDEN_ALIAS(x,y) \ - STRONG_ALIAS(_HIDDEN(x),y); \ - .hidden _HIDDEN(x) -#define _HIDDEN_FALIAS(x,y) \ - _HIDDEN_ALIAS(x,y); \ - .type _HIDDEN(x),@function - -/* - * For functions implemented in ASM that aren't syscalls. - * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names - * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names - */ -#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) -#define END_WEAK(x) END_STRONG(x); .weak x - - #define __END_HIDDEN(p,x) END(_CAT(p,x)); \ _HIDDEN_FALIAS(x, _CAT(p,x)); \ END(_HIDDEN(x)) diff --git a/lib/libc/arch/sparc64/sys/brk.S b/lib/libc/arch/sparc64/sys/brk.S index 03bcebd9fa1..653c693ac21 100644 --- a/lib/libc/arch/sparc64/sys/brk.S +++ b/lib/libc/arch/sparc64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.8 2021/10/25 14:38:10 jca Exp $ */ +/* $OpenBSD: brk.S,v 1.9 2022/01/01 23:47:14 guenther Exp $ */ /* $NetBSD: brk.S,v 1.9 2000/07/25 20:15:40 mycroft Exp $ */ /* @@ -49,7 +49,7 @@ __minbrk: OTYPE(__minbrk) .text -ENTRY(brk) +ENTRY_NB(brk) #ifdef __PIC__ PIC_PROLOGUE(%o5,%o4) set __minbrk, %o4 diff --git a/lib/libc/arch/sparc64/sys/sbrk.S b/lib/libc/arch/sparc64/sys/sbrk.S index a1663f43466..cdbde5ac243 100644 --- a/lib/libc/arch/sparc64/sys/sbrk.S +++ b/lib/libc/arch/sparc64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.6 2021/10/25 14:38:10 jca Exp $ */ +/* $OpenBSD: sbrk.S,v 1.7 2022/01/01 23:47:14 guenther Exp $ */ /* $NetBSD: sbrk.S,v 1.7 2000/07/25 15:14:46 mycroft Exp $ */ /* @@ -50,7 +50,7 @@ __curbrk: OTYPE(__curbrk) .text -ENTRY(sbrk) +ENTRY_NB(sbrk) #ifdef __PIC__ PIC_PROLOGUE(%o5,%o4) set __curbrk, %o3 |