summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/sparc
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2015-08-31 02:53:56 +0000
committerguenther <guenther@openbsd.org>2015-08-31 02:53:56 +0000
commit9b9d2a55a62c8e82206c25f94fcc7f4e2765250e (patch)
tree4e1fa28e81f1f4b2467c7facbde18ea61addb735 /lib/libc/arch/sparc
parentspaces snuck in (diff)
downloadwireguard-openbsd-9b9d2a55a62c8e82206c25f94fcc7f4e2765250e.tar.xz
wireguard-openbsd-9b9d2a55a62c8e82206c25f94fcc7f4e2765250e.zip
Add framework for resolving (pun intended) libc namespace issues, using
wrapper .h files and asm labels to let internal calls resolve directly and not be overridable or use the PLT. Then, apply that framework to most of the functions in stdio.h, string.h, err.h, and wchar.h. Delete the should-have-been-hidden-all-along _v?(err|warn)[cx]? symbols while here. tests clean on i386, amd64, sparc64, powerpc, and mips64 naming feedback from kettenis@ and millert@ ok kettenis@
Diffstat (limited to 'lib/libc/arch/sparc')
-rw-r--r--lib/libc/arch/sparc/DEFS.h25
-rw-r--r--lib/libc/arch/sparc/SYS.h4
-rw-r--r--lib/libc/arch/sparc/string/bzero.S3
-rw-r--r--lib/libc/arch/sparc/string/ffs.S3
-rw-r--r--lib/libc/arch/sparc/string/strlen.S3
5 files changed, 32 insertions, 6 deletions
diff --git a/lib/libc/arch/sparc/DEFS.h b/lib/libc/arch/sparc/DEFS.h
index 151b30fd946..13efbc6a428 100644
--- a/lib/libc/arch/sparc/DEFS.h
+++ b/lib/libc/arch/sparc/DEFS.h
@@ -30,7 +30,30 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: DEFS.h,v 1.3 2003/06/02 20:18:32 millert Exp $
+ * $OpenBSD: DEFS.h,v 1.4 2015/08/31 02:53:57 guenther 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
+ */
+#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x))
+#define END_WEAK(x) END_STRONG(x); .weak x
+
diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h
index 729c386bfaa..be262c8abfd 100644
--- a/lib/libc/arch/sparc/SYS.h
+++ b/lib/libc/arch/sparc/SYS.h
@@ -30,10 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.17 2015/04/07 01:27:07 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.18 2015/08/31 02:53:57 guenther Exp $
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <sys/syscall.h>
#include <machine/trap.h>
diff --git a/lib/libc/arch/sparc/string/bzero.S b/lib/libc/arch/sparc/string/bzero.S
index cb0a6845062..13ffe17f56b 100644
--- a/lib/libc/arch/sparc/string/bzero.S
+++ b/lib/libc/arch/sparc/string/bzero.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bzero.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
+/* $OpenBSD: bzero.S,v 1.5 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -134,3 +134,4 @@ Lstd:
1:
retl
nop
+END_WEAK(bzero)
diff --git a/lib/libc/arch/sparc/string/ffs.S b/lib/libc/arch/sparc/string/ffs.S
index ae885d896c4..530d7e706e6 100644
--- a/lib/libc/arch/sparc/string/ffs.S
+++ b/lib/libc/arch/sparc/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.5 2012/08/22 17:19:35 pascal Exp $ */
+/* $OpenBSD: ffs.S,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -83,6 +83,7 @@ ENTRY(ffs)
ldsb [%o2 + %o0], %o0
retl
add %o0, 24, %o0
+END_WEAK(ffs)
ffstab:
.byte -24,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 00-0f */
diff --git a/lib/libc/arch/sparc/string/strlen.S b/lib/libc/arch/sparc/string/strlen.S
index 0144bd00a36..c23bfbeff0d 100644
--- a/lib/libc/arch/sparc/string/strlen.S
+++ b/lib/libc/arch/sparc/string/strlen.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
+/* $OpenBSD: strlen.S,v 1.5 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -43,3 +43,4 @@ ENTRY(strlen)
inc %o0 ! always increment pointer
retl
sub %o0, %o1, %o0 ! return length (ptr - (origptr+1))
+END_STRONG(strlen)