summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/Makefile.inc4
-rw-r--r--lib/libc/arch/DEFS.h69
-rw-r--r--lib/libc/arch/amd64/DEFS.h69
-rw-r--r--lib/libc/arch/amd64/string/bcmp.S2
-rw-r--r--lib/libc/arch/amd64/string/bzero.S2
-rw-r--r--lib/libc/arch/amd64/string/memmove.S6
-rw-r--r--lib/libc/arch/amd64/sys/brk.S4
-rw-r--r--lib/libc/arch/amd64/sys/sbrk.S4
-rw-r--r--lib/libc/arch/sparc64/SYS.h28
-rw-r--r--lib/libc/arch/sparc64/sys/brk.S4
-rw-r--r--lib/libc/arch/sparc64/sys/sbrk.S4
-rw-r--r--sys/arch/amd64/include/asm.h23
-rw-r--r--sys/arch/sparc64/include/asm.h8
13 files changed, 105 insertions, 122 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
diff --git a/sys/arch/amd64/include/asm.h b/sys/arch/amd64/include/asm.h
index e642072c61a..fbcb748f883 100644
--- a/sys/arch/amd64/include/asm.h
+++ b/sys/arch/amd64/include/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.20 2021/09/04 22:15:33 bluhm Exp $ */
+/* $OpenBSD: asm.h,v 1.21 2022/01/01 23:47:14 guenther Exp $ */
/* $NetBSD: asm.h,v 1.2 2003/05/02 18:05:47 yamt Exp $ */
/*-
@@ -65,11 +65,15 @@
#endif
#define _ALIGN_TRAPS .align 16, 0xcc
-#define _GENTRY(x) .globl x; .type x,@function; x:
-#define _ENTRY(x) \
- .text; _ALIGN_TRAPS; _GENTRY(x)
-#define _NENTRY(x) \
- .text; _ALIGN_TEXT; _GENTRY(x)
+#define _FENTRY(x) .type x,@function; x:
+
+/* NB == No Binding: use .globl or .weak as necessary */
+#define NENTRY_NB(x) \
+ .text; _ALIGN_TEXT; _FENTRY(x)
+#define _ENTRY_NB(x) \
+ .text; _ALIGN_TRAPS; _FENTRY(x)
+#define _ENTRY(x) .globl x; _ENTRY_NB(x)
+#define _NENTRY(x) .globl x; NENTRY_NB(x)
#ifdef _KERNEL
#define KUTEXT .section .kutext, "ax", @progbits
@@ -81,14 +85,14 @@
#define IDTVEC(name) \
KUTEXT; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
-#define IDTVEC_NOALIGN(name) _GENTRY(X ## name)
-#define GENTRY(x) _GENTRY(x)
+#define GENTRY(x) .globl x; _FENTRY(x)
+#define IDTVEC_NOALIGN(name) GENTRY(X ## name)
#define KIDTVEC(name) \
.text; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
#define KIDTVEC_FALLTHROUGH(name) \
_ALIGN_TEXT; IDTVEC_NOALIGN(name)
#define KUENTRY(x) \
- KUTEXT; _ALIGN_TRAPS; _GENTRY(x)
+ KUTEXT; _ALIGN_TRAPS; GENTRY(x)
/* Return stack refill, to prevent speculation attacks on natural returns */
#define RET_STACK_REFILL_WITH_RCX \
@@ -165,6 +169,7 @@
#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
#define NENTRY(y) _NENTRY(_C_LABEL(y))
#define ASENTRY(y) _NENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
+#define ENTRY_NB(y) _ENTRY_NB(y); _PROF_PROLOGUE
#define END(y) .size y, . - y
#define STRONG_ALIAS(alias,sym) \
diff --git a/sys/arch/sparc64/include/asm.h b/sys/arch/sparc64/include/asm.h
index 45c79b88aa6..c94c4d12fcc 100644
--- a/sys/arch/sparc64/include/asm.h
+++ b/sys/arch/sparc64/include/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.13 2017/06/29 17:36:16 deraadt Exp $ */
+/* $OpenBSD: asm.h,v 1.14 2022/01/01 23:47:14 guenther Exp $ */
/* $NetBSD: asm.h,v 1.15 2000/08/02 22:24:39 eeh Exp $ */
/*
@@ -78,8 +78,9 @@
#define FTYPE(x) .type x,@function
#define OTYPE(x) .type x,@object
-#define _ENTRY(name) \
- .align 4; .globl name; .proc 1; FTYPE(name); name:
+#define _ENTRY_NB(name) \
+ .align 4; .proc 1; FTYPE(name); name:
+#define _ENTRY(name) .globl name; _ENTRY_NB(name)
#if defined(PROF) || defined(GPROF)
#define _PROF_PROLOGUE \
@@ -92,6 +93,7 @@
#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
#define NENTRY(name) _ENTRY(_C_LABEL(name))
+#define ENTRY_NB(name) _ENTRY_NB(name); _PROF_PROLOGUE
#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
#define FUNC(name) ASENTRY(name)
#define END(y) .size y, . - y