summaryrefslogtreecommitdiff
path: root/lib/libc/arch
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch')
-rw-r--r--lib/libc/arch/alpha/SYS.h25
-rw-r--r--lib/libc/arch/alpha/string/bcopy.S6
-rw-r--r--lib/libc/arch/alpha/string/bzero.S6
-rw-r--r--lib/libc/arch/alpha/string/ffs.S6
-rw-r--r--lib/libc/arch/alpha/string/memcpy.S6
-rw-r--r--lib/libc/arch/alpha/string/memmove.S6
-rw-r--r--lib/libc/arch/amd64/SYS.h32
-rw-r--r--lib/libc/arch/amd64/string/bcmp.S4
-rw-r--r--lib/libc/arch/amd64/string/bzero.S4
-rw-r--r--lib/libc/arch/amd64/string/ffs.S6
-rw-r--r--lib/libc/arch/amd64/string/memchr.S4
-rw-r--r--lib/libc/arch/amd64/string/memmove.S6
-rw-r--r--lib/libc/arch/amd64/string/memset.S4
-rw-r--r--lib/libc/arch/amd64/string/strchr.S6
-rw-r--r--lib/libc/arch/amd64/string/strcmp.S6
-rw-r--r--lib/libc/arch/amd64/string/strlen.S6
-rw-r--r--lib/libc/arch/amd64/string/strrchr.S6
-rw-r--r--lib/libc/arch/arm/SYS.h26
-rw-r--r--lib/libc/arch/arm/string/_memcpy.S5
-rw-r--r--lib/libc/arch/arm/string/bcopy.S5
-rw-r--r--lib/libc/arch/arm/string/bzero.S5
-rw-r--r--lib/libc/arch/arm/string/ffs.S5
-rw-r--r--lib/libc/arch/arm/string/memcmp.S5
-rw-r--r--lib/libc/arch/arm/string/memcpy.S5
-rw-r--r--lib/libc/arch/arm/string/memmove.S5
-rw-r--r--lib/libc/arch/arm/string/memset.S5
-rw-r--r--lib/libc/arch/arm/string/strcmp.S5
-rw-r--r--lib/libc/arch/arm/string/strncmp.S5
-rw-r--r--lib/libc/arch/hppa/SYS.h28
-rw-r--r--lib/libc/arch/hppa/string/memmove.S8
-rw-r--r--lib/libc/arch/hppa64/SYS.h28
-rw-r--r--lib/libc/arch/i386/SYS.h26
-rw-r--r--lib/libc/arch/i386/string/bcmp.S5
-rw-r--r--lib/libc/arch/i386/string/bzero.S5
-rw-r--r--lib/libc/arch/i386/string/ffs.S5
-rw-r--r--lib/libc/arch/i386/string/memchr.S5
-rw-r--r--lib/libc/arch/i386/string/memcmp.S5
-rw-r--r--lib/libc/arch/i386/string/memmove.S8
-rw-r--r--lib/libc/arch/i386/string/memset.S5
-rw-r--r--lib/libc/arch/i386/string/strcat.S3
-rw-r--r--lib/libc/arch/i386/string/strchr.S5
-rw-r--r--lib/libc/arch/i386/string/strcmp.S5
-rw-r--r--lib/libc/arch/i386/string/strcpy.S3
-rw-r--r--lib/libc/arch/i386/string/strncmp.S5
-rw-r--r--lib/libc/arch/i386/string/strrchr.S5
-rw-r--r--lib/libc/arch/m88k/SYS.h25
-rw-r--r--lib/libc/arch/mips64/SYS.h27
-rw-r--r--lib/libc/arch/mips64/string/bcmp.S6
-rw-r--r--lib/libc/arch/mips64/string/bcopy.S6
-rw-r--r--lib/libc/arch/mips64/string/bzero.S6
-rw-r--r--lib/libc/arch/mips64/string/ffs.S6
-rw-r--r--lib/libc/arch/mips64/string/strchr.S6
-rw-r--r--lib/libc/arch/mips64/string/strcmp.S6
-rw-r--r--lib/libc/arch/mips64/string/strlen.S6
-rw-r--r--lib/libc/arch/mips64/string/strrchr.S6
-rw-r--r--lib/libc/arch/powerpc/SYS.h25
-rw-r--r--lib/libc/arch/powerpc/string/memmove.S6
-rw-r--r--lib/libc/arch/sh/SYS.h27
-rw-r--r--lib/libc/arch/sh/string/bcopy.S5
-rw-r--r--lib/libc/arch/sh/string/ffs.S5
-rw-r--r--lib/libc/arch/sh/string/memcpy.S5
-rw-r--r--lib/libc/arch/sh/string/memmove.S5
-rw-r--r--lib/libc/arch/sh/string/memset.S9
-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
-rw-r--r--lib/libc/arch/sparc64/SYS.h26
-rw-r--r--lib/libc/arch/sparc64/string/ffs.S5
-rw-r--r--lib/libc/arch/sparc64/string/strlen.S5
-rw-r--r--lib/libc/arch/vax/DEFS.h25
-rw-r--r--lib/libc/arch/vax/SYS.h4
-rw-r--r--lib/libc/arch/vax/string/bcmp.S3
-rw-r--r--lib/libc/arch/vax/string/bcopy.S3
-rw-r--r--lib/libc/arch/vax/string/bzero.S3
-rw-r--r--lib/libc/arch/vax/string/ffs.S3
-rw-r--r--lib/libc/arch/vax/string/memcmp.S3
-rw-r--r--lib/libc/arch/vax/string/memcpy.S3
-rw-r--r--lib/libc/arch/vax/string/memmove.S3
-rw-r--r--lib/libc/arch/vax/string/memset.S3
-rw-r--r--lib/libc/arch/vax/string/strchr.S3
82 files changed, 520 insertions, 166 deletions
diff --git a/lib/libc/arch/alpha/SYS.h b/lib/libc/arch/alpha/SYS.h
index f1d15c6a501..e05715cca4b 100644
--- a/lib/libc/arch/alpha/SYS.h
+++ b/lib/libc/arch/alpha/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.10 2015/04/07 01:27:06 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.11 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: SYS.h,v 1.4 1996/10/17 03:03:53 cgd Exp $ */
/*
@@ -31,6 +31,29 @@
#include <machine/asm.h>
#include <sys/syscall.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); \
+ .size _HIDDEN(x), . - _HIDDEN(x)
+#define END_WEAK(x) END_STRONG(x); .weak x
+
#define CALLSYS_ERROR(name) \
CALLSYS_NOERROR(name); \
diff --git a/lib/libc/arch/alpha/string/bcopy.S b/lib/libc/arch/alpha/string/bcopy.S
index 65a7d55e407..8008a44c9db 100644
--- a/lib/libc/arch/alpha/string/bcopy.S
+++ b/lib/libc/arch/alpha/string/bcopy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.S,v 1.7 2014/11/30 19:43:54 deraadt Exp $ */
+/* $OpenBSD: bcopy.S,v 1.8 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bcopy.S,v 1.3 1996/10/17 03:08:11 cgd Exp $ */
/*
@@ -29,7 +29,7 @@
* rights to redistribute these changes.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define SRCREG a0
#define DSTREG a1
@@ -266,4 +266,4 @@ bcopy_ov_short:
ldq_u t2,0(SRCREG)
br zero,bcopy_da_finish
- END(bcopy)
+ END_WEAK(bcopy)
diff --git a/lib/libc/arch/alpha/string/bzero.S b/lib/libc/arch/alpha/string/bzero.S
index 5967dcb0f1a..159a2fd815b 100644
--- a/lib/libc/arch/alpha/string/bzero.S
+++ b/lib/libc/arch/alpha/string/bzero.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bzero.S,v 1.4 2005/08/07 16:40:13 espie Exp $ */
+/* $OpenBSD: bzero.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bzero.S,v 1.2 1996/10/17 03:08:12 cgd Exp $ */
/*
@@ -28,7 +28,7 @@
* rights to redistribute these changes.
*/
-#include <machine/asm.h>
+#include "SYS.h"
LEAF(bzero,2)
ble a1,bzero_done
@@ -108,4 +108,4 @@ bzero_finish_lp_done:
bzero_done:
RET
- END(bzero)
+ END_WEAK(bzero)
diff --git a/lib/libc/arch/alpha/string/ffs.S b/lib/libc/arch/alpha/string/ffs.S
index 9ad222a4806..6600b3aeeb2 100644
--- a/lib/libc/arch/alpha/string/ffs.S
+++ b/lib/libc/arch/alpha/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.2 2004/10/01 04:08:45 jsg Exp $ */
+/* $OpenBSD: ffs.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: ffs.S,v 1.3 1996/10/17 03:08:13 cgd Exp $ */
/*
@@ -32,7 +32,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
LEAF(ffs, 1)
addl a0, 0, t0
@@ -89,4 +89,4 @@ Ldone:
Lallzero:
bis zero, zero, v0
RET
-END(ffs)
+END_WEAK(ffs)
diff --git a/lib/libc/arch/alpha/string/memcpy.S b/lib/libc/arch/alpha/string/memcpy.S
index 695872491ea..ffdcea3b832 100644
--- a/lib/libc/arch/alpha/string/memcpy.S
+++ b/lib/libc/arch/alpha/string/memcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcpy.S,v 1.5 2014/11/30 19:43:54 deraadt Exp $ */
+/* $OpenBSD: memcpy.S,v 1.6 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bcopy.S,v 1.3 1996/10/17 03:08:11 cgd Exp $ */
/*
@@ -29,7 +29,7 @@
* rights to redistribute these changes.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define SRCREG a1
#define DSTREG a0
@@ -197,4 +197,4 @@ bcopy_da_finish:
bcopy_done:
RET
- END(memcpy)
+ END_STRONG(memcpy)
diff --git a/lib/libc/arch/alpha/string/memmove.S b/lib/libc/arch/alpha/string/memmove.S
index dc74e8c3de4..f0ebde808e8 100644
--- a/lib/libc/arch/alpha/string/memmove.S
+++ b/lib/libc/arch/alpha/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.5 2014/11/30 19:43:54 deraadt Exp $ */
+/* $OpenBSD: memmove.S,v 1.6 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bcopy.S,v 1.3 1996/10/17 03:08:11 cgd Exp $ */
/*
@@ -29,7 +29,7 @@
* rights to redistribute these changes.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define SRCREG a1
#define DSTREG a0
@@ -270,4 +270,4 @@ bcopy_ov_short:
ldq_u t2,0(SRCREG)
br zero,bcopy_da_finish
- END(memmove)
+ END_STRONG(memmove)
diff --git a/lib/libc/arch/amd64/SYS.h b/lib/libc/arch/amd64/SYS.h
index a61385fc13a..d96101b77c4 100644
--- a/lib/libc/arch/amd64/SYS.h
+++ b/lib/libc/arch/amd64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.13 2015/08/26 01:54:09 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.14 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,18 +38,40 @@
#include <machine/asm.h>
#include <sys/syscall.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
+
#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall
#define SYSENTRY(x) \
SYSENTRY_HIDDEN(x); \
- .weak _C_LABEL(x); \
- _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x)
+ WEAK_ALIAS(x, _thread_sys_##x)
#define SYSENTRY_HIDDEN(x) \
- ENTRY(_thread_sys_ ## x) \
+ ENTRY(_thread_sys_ ## x); \
+ _HIDDEN_FALIAS(x,_thread_sys_##x)
#define SYSEXIT_HIDDEN(x) END(_thread_sys_ ## x)
-#define SYSEXIT(x) SYSEXIT_HIDDEN(x); END(x)
+#define SYSEXIT(x) SYSEXIT_HIDDEN(x); END(x)
#define CERROR _C_LABEL(__cerror)
#define _CERROR _C_LABEL(___cerror)
diff --git a/lib/libc/arch/amd64/string/bcmp.S b/lib/libc/arch/amd64/string/bcmp.S
index 82d239bd233..fc7afe5b8be 100644
--- a/lib/libc/arch/amd64/string/bcmp.S
+++ b/lib/libc/arch/amd64/string/bcmp.S
@@ -1,4 +1,4 @@
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(bcmp)
xorl %eax,%eax /* clear return value */
@@ -18,4 +18,4 @@ ENTRY(bcmp)
L1: incl %eax
L2: ret
-END(bcmp)
+END_WEAK(bcmp)
diff --git a/lib/libc/arch/amd64/string/bzero.S b/lib/libc/arch/amd64/string/bzero.S
index e91dd882115..eb3a7713be7 100644
--- a/lib/libc/arch/amd64/string/bzero.S
+++ b/lib/libc/arch/amd64/string/bzero.S
@@ -4,7 +4,7 @@
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(bzero)
movq %rsi,%rdx
@@ -38,4 +38,4 @@ L1: movq %rdx,%rcx /* zero remainder by bytes */
stosb
ret
-END(bzero)
+END_WEAK(bzero)
diff --git a/lib/libc/arch/amd64/string/ffs.S b/lib/libc/arch/amd64/string/ffs.S
index 6738183a4ec..3e2d81e56b5 100644
--- a/lib/libc/arch/amd64/string/ffs.S
+++ b/lib/libc/arch/amd64/string/ffs.S
@@ -1,11 +1,11 @@
-/* $OpenBSD: ffs.S,v 1.2 2015/05/29 07:21:09 uebayasi Exp $ */
+/* $OpenBSD: ffs.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
/*
* 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>
+#include "SYS.h"
ENTRY(ffs)
bsfl %edi,%eax
@@ -16,4 +16,4 @@ ENTRY(ffs)
_ALIGN_TEXT
L1: xorl %eax,%eax /* clear result */
ret
-END(ffs)
+END_WEAK(ffs)
diff --git a/lib/libc/arch/amd64/string/memchr.S b/lib/libc/arch/amd64/string/memchr.S
index 9458f87eb4c..4fe2d4d996a 100644
--- a/lib/libc/arch/amd64/string/memchr.S
+++ b/lib/libc/arch/amd64/string/memchr.S
@@ -4,7 +4,7 @@
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memchr)
movb %sil,%al /* set character to search for */
@@ -19,4 +19,4 @@ ENTRY(memchr)
ret
L1: xorq %rax,%rax
ret
-END(memchr)
+END_STRONG(memchr)
diff --git a/lib/libc/arch/amd64/string/memmove.S b/lib/libc/arch/amd64/string/memmove.S
index f8bd571252c..8a924a06801 100644
--- a/lib/libc/arch/amd64/string/memmove.S
+++ b/lib/libc/arch/amd64/string/memmove.S
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* memmove (dst,src,cnt)
@@ -86,5 +86,5 @@ ENTRY(memmove)
cld
ret
// END(memcpy)
-END(memmove)
-END(bcopy)
+END_STRONG(memmove)
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/amd64/string/memset.S b/lib/libc/arch/amd64/string/memset.S
index 5b9d9a16ffc..779ea53b9f8 100644
--- a/lib/libc/arch/amd64/string/memset.S
+++ b/lib/libc/arch/amd64/string/memset.S
@@ -4,7 +4,7 @@
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memset)
movq %rsi,%rax
@@ -53,4 +53,4 @@ L1: rep
movq %r11,%rax
ret
-END(memset)
+END_STRONG(memset)
diff --git a/lib/libc/arch/amd64/string/strchr.S b/lib/libc/arch/amd64/string/strchr.S
index a2f02a09664..285ce084114 100644
--- a/lib/libc/arch/amd64/string/strchr.S
+++ b/lib/libc/arch/amd64/string/strchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.S,v 1.6 2015/05/29 07:21:09 uebayasi Exp $ */
+/* $OpenBSD: strchr.S,v 1.7 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strchr.S,v 1.7 2014/03/22 19:16:34 jakllsch Exp $ */
/*-
@@ -32,7 +32,7 @@
/* See comments in strlen.S about checking words for byte values */
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(index, strchr)
@@ -123,4 +123,4 @@ ENTRY(strchr)
sar %cl,%r10 /* top bytes 0xff */
and %r10,%rax /* clear lsb from unwanted low bytes */
jmp 21b
-END(strchr)
+END_STRONG(strchr)
diff --git a/lib/libc/arch/amd64/string/strcmp.S b/lib/libc/arch/amd64/string/strcmp.S
index 2aa55f45f15..752d8e8c1d7 100644
--- a/lib/libc/arch/amd64/string/strcmp.S
+++ b/lib/libc/arch/amd64/string/strcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcmp.S,v 1.5 2015/05/29 07:21:09 uebayasi Exp $ */
+/* $OpenBSD: strcmp.S,v 1.6 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strcmp.S,v 1.2 2014/03/22 19:16:34 jakllsch Exp $ */
/*
@@ -6,7 +6,7 @@
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(strcmp)
/*
@@ -69,4 +69,4 @@ ENTRY(strcmp)
movzbq %dl,%rdx
subq %rdx,%rax
ret
-END(strcmp)
+END_STRONG(strcmp)
diff --git a/lib/libc/arch/amd64/string/strlen.S b/lib/libc/arch/amd64/string/strlen.S
index 7e7395385f2..bde5df68e6e 100644
--- a/lib/libc/arch/amd64/string/strlen.S
+++ b/lib/libc/arch/amd64/string/strlen.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.S,v 1.4 2015/05/29 07:21:09 uebayasi Exp $ */
+/* $OpenBSD: strlen.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strlen.S,v 1.6 2014/03/22 19:16:34 jakllsch Exp $ */
/*-
@@ -35,7 +35,7 @@
* (Only the long comment really remains his work!)
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* There are many well known branch-free sequences which are used
@@ -154,4 +154,4 @@ ENTRY(strlen)
dec %rsi
or %rsi,%rdx /* low bytes now non-zero */
jmp 2b
-END(strlen)
+END_STRONG(strlen)
diff --git a/lib/libc/arch/amd64/string/strrchr.S b/lib/libc/arch/amd64/string/strrchr.S
index 802be5a2831..44a3839cf96 100644
--- a/lib/libc/arch/amd64/string/strrchr.S
+++ b/lib/libc/arch/amd64/string/strrchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strrchr.S,v 1.6 2015/05/29 07:21:09 uebayasi Exp $ */
+/* $OpenBSD: strrchr.S,v 1.7 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strrchr.S,v 1.3 2014/03/22 19:16:34 jakllsch Exp $ */
/*
@@ -6,7 +6,7 @@
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(rindex, strrchr)
@@ -121,4 +121,4 @@ ENTRY(strrchr)
.Ldone:
ret
-END(strrchr)
+END_STRONG(strrchr)
diff --git a/lib/libc/arch/arm/SYS.h b/lib/libc/arch/arm/SYS.h
index ce42349711a..df72e5c1b3c 100644
--- a/lib/libc/arch/arm/SYS.h
+++ b/lib/libc/arch/arm/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.10 2015/08/26 01:54:09 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.11 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */
/*-
@@ -38,6 +38,30 @@
#include <machine/asm.h>
#include <sys/syscall.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
+
+
#define SYSENTRY(x) \
.weak _C_LABEL(x); \
_C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \
diff --git a/lib/libc/arch/arm/string/_memcpy.S b/lib/libc/arch/arm/string/_memcpy.S
index dee8de3e080..ef2ccc442b9 100644
--- a/lib/libc/arch/arm/string/_memcpy.S
+++ b/lib/libc/arch/arm/string/_memcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: _memcpy.S,v 1.4 2015/06/08 14:22:05 jsg Exp $ */
+/* $OpenBSD: _memcpy.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: _memcpy.S,v 1.4 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* This is one fun bit of code ...
@@ -462,3 +462,4 @@ ENTRY(_memcpy)
.Lmemcpy_bsrcul1l4:
add r1, r1, #1
b .Lmemcpy_bl4
+END(_memcpy)
diff --git a/lib/libc/arch/arm/string/bcopy.S b/lib/libc/arch/arm/string/bcopy.S
index 3953fef1732..f71b5ce7cbd 100644
--- a/lib/libc/arch/arm/string/bcopy.S
+++ b/lib/libc/arch/arm/string/bcopy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.S,v 1.3 2008/06/26 05:42:04 ray Exp $ */
+/* $OpenBSD: bcopy.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bcopy.S,v 1.2 2001/07/16 05:50:06 matt Exp $ */
/*-
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/* bcopy = memcpy/memmove with arguments reversed. */
@@ -40,3 +40,4 @@ ENTRY(bcopy)
eor r1, r0, r1
eor r0, r1, r0
b PIC_SYM(_C_LABEL(_memcpy), PLT)
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/arm/string/bzero.S b/lib/libc/arch/arm/string/bzero.S
index 40430a86873..419e2bbdc9d 100644
--- a/lib/libc/arch/arm/string/bzero.S
+++ b/lib/libc/arch/arm/string/bzero.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bzero.S,v 1.3 2008/06/26 05:42:04 ray Exp $ */
+/* $OpenBSD: bzero.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: bzero.S,v 1.2 2001/07/16 05:50:06 matt Exp $ */
/*-
@@ -30,9 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(bzero)
mov r2, r1
mov r1, #0
b PIC_SYM(_C_LABEL(memset), PLT)
+END_WEAK(bzero)
diff --git a/lib/libc/arch/arm/string/ffs.S b/lib/libc/arch/arm/string/ffs.S
index 9dd7e5aef2f..7f4b289d860 100644
--- a/lib/libc/arch/arm/string/ffs.S
+++ b/lib/libc/arch/arm/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.3 2009/10/28 06:49:54 deraadt Exp $ */
+/* $OpenBSD: ffs.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: ffs.S,v 1.5 2003/04/05 23:08:52 bjh21 Exp $ */
/*
* Copyright (c) 2001 Christopher Gilbert
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* ffs - find first set bit, this algorithm isolates the first set
@@ -61,6 +61,7 @@ ENTRY(ffs)
ldrneb r0, [ r2, r0, lsr #26 ]
mov pc, lr
+END_WEAK(ffs)
.text;
.type .L_ffs_table, _ASM_TYPE_OBJECT;
.L_ffs_table:
diff --git a/lib/libc/arch/arm/string/memcmp.S b/lib/libc/arch/arm/string/memcmp.S
index 3a564c7338a..f7c5c966663 100644
--- a/lib/libc/arch/arm/string/memcmp.S
+++ b/lib/libc/arch/arm/string/memcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcmp.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */
+/* $OpenBSD: memcmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: memcmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */
/*
@@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memcmp)
/* if (len == 0) return 0 */
@@ -50,3 +50,4 @@ ENTRY(memcmp)
beq 1b
sub r0, r2, r3
mov pc, lr
+END_STRONG(memcmp)
diff --git a/lib/libc/arch/arm/string/memcpy.S b/lib/libc/arch/arm/string/memcpy.S
index 6aeb5b84bac..5797c6d6f33 100644
--- a/lib/libc/arch/arm/string/memcpy.S
+++ b/lib/libc/arch/arm/string/memcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcpy.S,v 1.4 2014/11/30 19:43:56 deraadt Exp $ */
+/* $OpenBSD: memcpy.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: memcpy.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* XXX
@@ -42,3 +42,4 @@ ENTRY(memcpy)
stmfd sp!, {r0, lr}
bl PIC_SYM(_C_LABEL(_memcpy), PLT)
ldmfd sp!, {r0, pc}
+END_STRONG(memcpy)
diff --git a/lib/libc/arch/arm/string/memmove.S b/lib/libc/arch/arm/string/memmove.S
index 8244afb7de1..c2f107e3cd8 100644
--- a/lib/libc/arch/arm/string/memmove.S
+++ b/lib/libc/arch/arm/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.3 2008/06/26 05:42:04 ray Exp $ */
+/* $OpenBSD: memmove.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: memmove.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*-
@@ -30,9 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memmove)
stmfd sp!, {r0, lr}
bl PIC_SYM(_C_LABEL(_memcpy), PLT)
ldmfd sp!, {r0, pc}
+END_STRONG(memmove)
diff --git a/lib/libc/arch/arm/string/memset.S b/lib/libc/arch/arm/string/memset.S
index a4c3d158938..5ab2f9f3bcd 100644
--- a/lib/libc/arch/arm/string/memset.S
+++ b/lib/libc/arch/arm/string/memset.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memset.S,v 1.3 2015/06/08 14:22:05 jsg Exp $ */
+/* $OpenBSD: memset.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: memset.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* Sets a block of memory to the specified value
@@ -127,3 +127,4 @@ ENTRY(memset)
ldmfd sp!, {r0}
mov pc, lr /* Exit */
+END_STRONG(memset)
diff --git a/lib/libc/arch/arm/string/strcmp.S b/lib/libc/arch/arm/string/strcmp.S
index ea6078e7f9c..223610d0925 100644
--- a/lib/libc/arch/arm/string/strcmp.S
+++ b/lib/libc/arch/arm/string/strcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcmp.S,v 1.3 2005/08/07 16:40:14 espie Exp $ */
+/* $OpenBSD: strcmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strcmp.S,v 1.3 2003/04/05 23:08:52 bjh21 Exp $ */
/*
@@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(strcmp)
1:
@@ -40,3 +40,4 @@ ENTRY(strcmp)
beq 1b
sub r0, r2, r3
mov pc, lr
+END_STRONG(strcmp)
diff --git a/lib/libc/arch/arm/string/strncmp.S b/lib/libc/arch/arm/string/strncmp.S
index f8960bbc84b..1014d5dc4ea 100644
--- a/lib/libc/arch/arm/string/strncmp.S
+++ b/lib/libc/arch/arm/string/strncmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strncmp.S,v 1.4 2009/05/03 05:09:40 drahn Exp $ */
+/* $OpenBSD: strncmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/* $NetBSD: strncmp.S,v 1.2 2003/04/05 23:08:52 bjh21 Exp $ */
/*
@@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(strncmp)
/* if (len == 0) return 0 */
@@ -51,3 +51,4 @@ ENTRY(strncmp)
beq 1b
sub r0, r2, r3
mov pc, lr
+END_STRONG(strncmp)
diff --git a/lib/libc/arch/hppa/SYS.h b/lib/libc/arch/hppa/SYS.h
index a2dbef50244..b07287224b2 100644
--- a/lib/libc/arch/hppa/SYS.h
+++ b/lib/libc/arch/hppa/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.17 2015/04/07 01:27:06 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.18 2015/08/31 02:53:56 guenther Exp $ */
/*
* Copyright (c) 1998-2002 Michael Shalayeff
@@ -33,6 +33,32 @@
#include <machine/vmparam.h>
#undef _LOCORE
+/*
+ * 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.
+ * EXIT_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names
+ * EXIT_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names
+ */
+#define EXIT_STRONG(x) EXIT(x) !\
+ _HIDDEN_FALIAS(x,x) !\
+ .size _HIDDEN(x), . - _HIDDEN(x)
+#define EXIT_WEAK(x) EXIT_STRONG(x) !\
+ .weak x
+
+
#define SYSENTRY(x) !\
LEAF_ENTRY(__CONCAT(_thread_sys_,x)) !\
WEAK_ALIAS(x,__CONCAT(_thread_sys_,x))
diff --git a/lib/libc/arch/hppa/string/memmove.S b/lib/libc/arch/hppa/string/memmove.S
index 8ed210a168a..4b14de65110 100644
--- a/lib/libc/arch/hppa/string/memmove.S
+++ b/lib/libc/arch/hppa/string/memmove.S
@@ -31,11 +31,7 @@
*/
-
-#undef _LOCORE
-#define _LOCORE
-#include <machine/asm.h>
-#include <machine/frame.h>
+#include "SYS.h"
LEAF_ENTRY(bcopy)
@@ -155,6 +151,6 @@ $bcopy_r.done
bv 0(rp)
nop
-EXIT(bcopy)
+EXIT_WEAK(bcopy)
.end
diff --git a/lib/libc/arch/hppa64/SYS.h b/lib/libc/arch/hppa64/SYS.h
index 510ab2c5fba..c61fcface6b 100644
--- a/lib/libc/arch/hppa64/SYS.h
+++ b/lib/libc/arch/hppa64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.7 2015/04/07 01:27:06 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.8 2015/08/31 02:53:56 guenther Exp $ */
/*
* Copyright (c) 1998-2002 Michael Shalayeff
@@ -33,6 +33,32 @@
#include <machine/vmparam.h>
#undef _LOCORE
+/*
+ * 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.
+ * EXIT_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names
+ * EXIT_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names
+ */
+#define EXIT_STRONG(x) EXIT(x) !\
+ _HIDDEN_FALIAS(x,x) !\
+ .size _HIDDEN(x), . - _HIDDEN(x)
+#define EXIT_WEAK(x) EXIT_STRONG(x) !\
+ .weak x
+
+
#define SYSENTRY(x) !\
LEAF_ENTRY(__CONCAT(_thread_sys_,x)) !\
WEAK_ALIAS(x,__CONCAT(_thread_sys_,x))
diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h
index 9328b480020..4e1a54f003e 100644
--- a/lib/libc/arch/i386/SYS.h
+++ b/lib/libc/arch/i386/SYS.h
@@ -29,12 +29,36 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.21 2015/08/26 01:54:09 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.22 2015/08/31 02:53:56 guenther Exp $
*/
#include <machine/asm.h>
#include <sys/syscall.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
+
+
/*
* Design note:
*
diff --git a/lib/libc/arch/i386/string/bcmp.S b/lib/libc/arch/i386/string/bcmp.S
index a5b46ae745a..b55c93a6e14 100644
--- a/lib/libc/arch/i386/string/bcmp.S
+++ b/lib/libc/arch/i386/string/bcmp.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: bcmp.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: bcmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(bcmp)
pushl %edi
@@ -30,3 +30,4 @@ L1: incl %eax
L2: popl %esi
popl %edi
ret
+END_WEAK(bcmp)
diff --git a/lib/libc/arch/i386/string/bzero.S b/lib/libc/arch/i386/string/bzero.S
index eea840afdca..43251b5cdff 100644
--- a/lib/libc/arch/i386/string/bzero.S
+++ b/lib/libc/arch/i386/string/bzero.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: bzero.S,v 1.4 2007/05/25 20:32:29 krw Exp $ */
+/* $OpenBSD: bzero.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(bzero)
pushl %edi
@@ -41,3 +41,4 @@ L1: movl %edx,%ecx /* zero remainder by bytes */
popl %edi
ret
+END_WEAK(bzero)
diff --git a/lib/libc/arch/i386/string/ffs.S b/lib/libc/arch/i386/string/ffs.S
index 96affabed07..4de8c6aaaf0 100644
--- a/lib/libc/arch/i386/string/ffs.S
+++ b/lib/libc/arch/i386/string/ffs.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: ffs.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: ffs.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(ffs)
bsfl 4(%esp),%eax
@@ -15,3 +15,4 @@ ENTRY(ffs)
.align 2
L1: xorl %eax,%eax /* clear result */
ret
+END_WEAK(ffs)
diff --git a/lib/libc/arch/i386/string/memchr.S b/lib/libc/arch/i386/string/memchr.S
index d6bcbe688b5..87191eb0f2d 100644
--- a/lib/libc/arch/i386/string/memchr.S
+++ b/lib/libc/arch/i386/string/memchr.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: memchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: memchr.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memchr)
pushl %edi
@@ -24,3 +24,4 @@ ENTRY(memchr)
L1: xorl %eax,%eax
popl %edi
ret
+END_STRONG(memchr)
diff --git a/lib/libc/arch/i386/string/memcmp.S b/lib/libc/arch/i386/string/memcmp.S
index 1be189aefbb..171af0734b1 100644
--- a/lib/libc/arch/i386/string/memcmp.S
+++ b/lib/libc/arch/i386/string/memcmp.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: memcmp.S,v 1.4 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: memcmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memcmp)
pushl %edi
@@ -41,3 +41,4 @@ L6: movzbl -1(%edi),%eax /* Perform unsigned comparison */
popl %esi
popl %edi
ret
+END_STRONG(memcmp)
diff --git a/lib/libc/arch/i386/string/memmove.S b/lib/libc/arch/i386/string/memmove.S
index a1621ec1f1e..afa465aa4dd 100644
--- a/lib/libc/arch/i386/string/memmove.S
+++ b/lib/libc/arch/i386/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.5 2014/12/02 03:07:13 tedu Exp $ */
+/* $OpenBSD: memmove.S,v 1.6 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
@@ -33,8 +33,7 @@
* SUCH DAMAGE.
*/
-#include <machine/param.h>
-#include <machine/asm.h>
+#include "SYS.h"
/*
* Emulate bcopy() by swapping the first two arguments, and jumping
@@ -105,4 +104,5 @@ docopyf:
popl %esi
cld
ret
-
+END_STRONG(memmove)
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/i386/string/memset.S b/lib/libc/arch/i386/string/memset.S
index 912b74a19e1..0eb4381558e 100644
--- a/lib/libc/arch/i386/string/memset.S
+++ b/lib/libc/arch/i386/string/memset.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: memset.S,v 1.4 2007/05/25 20:32:29 krw Exp $ */
+/* $OpenBSD: memset.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(memset)
pushl %edi
@@ -53,3 +53,4 @@ L1: rep
popl %ebx
popl %edi
ret
+END_STRONG(memset)
diff --git a/lib/libc/arch/i386/string/strcat.S b/lib/libc/arch/i386/string/strcat.S
index 60fdd554ee0..fb8008e8035 100644
--- a/lib/libc/arch/i386/string/strcat.S
+++ b/lib/libc/arch/i386/string/strcat.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcat.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: strcat.S,v 1.9 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
@@ -71,3 +71,4 @@ L1: movb (%edx),%al /* unroll loop, but not too much */
L2: popl %eax /* pop destination address */
popl %edi /* restore edi */
ret
+END(strcat)
diff --git a/lib/libc/arch/i386/string/strchr.S b/lib/libc/arch/i386/string/strchr.S
index f8cd8e6589a..3792d2292ab 100644
--- a/lib/libc/arch/i386/string/strchr.S
+++ b/lib/libc/arch/i386/string/strchr.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: strchr.S,v 1.6 2015/05/15 22:29:37 millert Exp $ */
+/* $OpenBSD: strchr.S,v 1.7 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(index, strchr)
@@ -22,3 +22,4 @@ L1:
xorl %eax,%eax
L2:
ret
+END_STRONG(strchr)
diff --git a/lib/libc/arch/i386/string/strcmp.S b/lib/libc/arch/i386/string/strcmp.S
index 22ba5460eae..373232419e9 100644
--- a/lib/libc/arch/i386/string/strcmp.S
+++ b/lib/libc/arch/i386/string/strcmp.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: strcmp.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: strcmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* NOTE: I've unrolled the loop eight times: large enough to make a
@@ -79,3 +79,4 @@ L3: movzbl (%eax),%eax /* unsigned comparison */
movzbl (%edx),%edx
subl %edx,%eax
ret
+END_STRONG(strcmp)
diff --git a/lib/libc/arch/i386/string/strcpy.S b/lib/libc/arch/i386/string/strcpy.S
index 341eb6c39a9..f72990f8f0e 100644
--- a/lib/libc/arch/i386/string/strcpy.S
+++ b/lib/libc/arch/i386/string/strcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcpy.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: strcpy.S,v 1.9 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
@@ -61,3 +61,4 @@ L1: movb (%edx),%al /* unroll loop, but not too much */
jnz L1
L2: popl %eax /* pop dst address */
ret
+END(strcpy)
diff --git a/lib/libc/arch/i386/string/strncmp.S b/lib/libc/arch/i386/string/strncmp.S
index 5aa88d7e798..6e480c95f2e 100644
--- a/lib/libc/arch/i386/string/strncmp.S
+++ b/lib/libc/arch/i386/string/strncmp.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: strncmp.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/* $OpenBSD: strncmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* NOTE: I've unrolled the loop eight times: large enough to make a
@@ -111,3 +111,4 @@ L3: movzbl (%eax),%eax /* unsigned comparision */
L4: xorl %eax,%eax
popl %ebx
ret
+END_STRONG(strncmp)
diff --git a/lib/libc/arch/i386/string/strrchr.S b/lib/libc/arch/i386/string/strrchr.S
index 738c369b378..e1f5cc2e32e 100644
--- a/lib/libc/arch/i386/string/strrchr.S
+++ b/lib/libc/arch/i386/string/strrchr.S
@@ -1,10 +1,10 @@
-/* $OpenBSD: strrchr.S,v 1.6 2015/05/15 22:29:37 millert Exp $ */
+/* $OpenBSD: strrchr.S,v 1.7 2015/08/31 02:53:56 guenther Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(rindex, strrchr)
@@ -25,3 +25,4 @@ L2:
jnz L1
popl %ebx
ret
+END_STRONG(strrchr)
diff --git a/lib/libc/arch/m88k/SYS.h b/lib/libc/arch/m88k/SYS.h
index 70292c9d585..0c48e6cedeb 100644
--- a/lib/libc/arch/m88k/SYS.h
+++ b/lib/libc/arch/m88k/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.19 2015/04/07 01:27:06 guenther Exp $*/
+/* $OpenBSD: SYS.h,v 1.20 2015/08/31 02:53:56 guenther Exp $*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -37,6 +37,29 @@
#include <sys/syscall.h>
#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
+
+
#define __CONCAT(p,x) p##x
#define __ENTRY(p,x) ENTRY(__CONCAT(p,x))
#define __END(p,x) END(__CONCAT(p,x))
diff --git a/lib/libc/arch/mips64/SYS.h b/lib/libc/arch/mips64/SYS.h
index 55926724eb9..f9b2063dc5b 100644
--- a/lib/libc/arch/mips64/SYS.h
+++ b/lib/libc/arch/mips64/SYS.h
@@ -29,12 +29,37 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.7 2015/04/07 01:27:06 guenther Exp $
+ * $OpenBSD: SYS.h,v 1.8 2015/08/31 02:53:56 guenther Exp $
*/
#include <sys/syscall.h>
#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); \
+ .size _HIDDEN(x), . - _HIDDEN(x)
+#define END_WEAK(x) END_STRONG(x); .weak x
+
+
#define CERROR _C_LABEL(__cerror)
#define _CERROR _C_LABEL(___cerror)
diff --git a/lib/libc/arch/mips64/string/bcmp.S b/lib/libc/arch/mips64/string/bcmp.S
index 2ff4a6e817e..fe51d35fce4 100644
--- a/lib/libc/arch/mips64/string/bcmp.S
+++ b/lib/libc/arch/mips64/string/bcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcmp.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */
+/* $OpenBSD: bcmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/* bcmp(s1, s2, n) */
@@ -109,4 +109,4 @@ nomatch:
j ra
li v0, 1
.set reorder
-END(bcmp)
+END_WEAK(bcmp)
diff --git a/lib/libc/arch/mips64/string/bcopy.S b/lib/libc/arch/mips64/string/bcopy.S
index e5098a2cffc..bd63a62a890 100644
--- a/lib/libc/arch/mips64/string/bcopy.S
+++ b/lib/libc/arch/mips64/string/bcopy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */
+/* $OpenBSD: bcopy.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/* bcopy(s1, s2, n) */
@@ -116,4 +116,4 @@ smallcpy:
j ra
nop
.set reorder
-END(bcopy)
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/mips64/string/bzero.S b/lib/libc/arch/mips64/string/bzero.S
index 0b0c477aaa7..8fae96ec188 100644
--- a/lib/libc/arch/mips64/string/bzero.S
+++ b/lib/libc/arch/mips64/string/bzero.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bzero.S,v 1.5 2009/12/11 05:10:17 miod Exp $ */
+/* $OpenBSD: bzero.S,v 1.6 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/* bzero(s1, n) */
@@ -63,4 +63,4 @@ smallclr:
2:
j ra
nop
-END(bzero)
+END_WEAK(bzero)
diff --git a/lib/libc/arch/mips64/string/ffs.S b/lib/libc/arch/mips64/string/ffs.S
index 0fa0803e316..f09de46a930 100644
--- a/lib/libc/arch/mips64/string/ffs.S
+++ b/lib/libc/arch/mips64/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */
+/* $OpenBSD: ffs.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/* bit = ffs(value) */
@@ -46,4 +46,4 @@ LEAF(ffs, 0)
beq v1, zero, 1b # no, continue
done:
j ra
-END(ffs)
+END_WEAK(ffs)
diff --git a/lib/libc/arch/mips64/string/strchr.S b/lib/libc/arch/mips64/string/strchr.S
index a5a12c53940..05f50f0da73 100644
--- a/lib/libc/arch/mips64/string/strchr.S
+++ b/lib/libc/arch/mips64/string/strchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */
+/* $OpenBSD: strchr.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(index, strchr)
@@ -48,4 +48,4 @@ notfnd:
fnd:
dsubu v0, a0, 1
j ra
-END(strchr)
+END_STRONG(strchr)
diff --git a/lib/libc/arch/mips64/string/strcmp.S b/lib/libc/arch/mips64/string/strcmp.S
index 7193a6bf131..282cc929441 100644
--- a/lib/libc/arch/mips64/string/strcmp.S
+++ b/lib/libc/arch/mips64/string/strcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcmp.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */
+/* $OpenBSD: strcmp.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* NOTE: this version assumes unsigned chars in order to be "8 bit clean".
@@ -55,4 +55,4 @@ NotEq:
LessOrEq:
dsubu v0, zero, t1
j ra
-END(strcmp)
+END_STRONG(strcmp)
diff --git a/lib/libc/arch/mips64/string/strlen.S b/lib/libc/arch/mips64/string/strlen.S
index 5bc80bf847c..7817d753fdb 100644
--- a/lib/libc/arch/mips64/string/strlen.S
+++ b/lib/libc/arch/mips64/string/strlen.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */
+/* $OpenBSD: strlen.S,v 1.5 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
LEAF(strlen, 0)
.set reorder
@@ -42,4 +42,4 @@ LEAF(strlen, 0)
bne v0, zero, 1b # continue if not end
dsubu v0, a0, v1 # compute length - 1 for '\0' char
j ra
-END(strlen)
+END_STRONG(strlen)
diff --git a/lib/libc/arch/mips64/string/strrchr.S b/lib/libc/arch/mips64/string/strrchr.S
index a7f5b74c320..ad35b84cb95 100644
--- a/lib/libc/arch/mips64/string/strrchr.S
+++ b/lib/libc/arch/mips64/string/strrchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strrchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */
+/* $OpenBSD: strrchr.S,v 1.3 2015/08/31 02:53:56 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
WEAK_ALIAS(rindex, strrchr)
@@ -46,4 +46,4 @@ LEAF(strrchr, 0)
2:
bne a3, zero, 1b # continue if not end
j ra
-END(strrchr)
+END_STRONG(strrchr)
diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h
index 6303d68f7b6..b9cd88b7c30 100644
--- a/lib/libc/arch/powerpc/SYS.h
+++ b/lib/libc/arch/powerpc/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.17 2015/08/23 15:51:28 kettenis Exp $ */
+/* $OpenBSD: SYS.h,v 1.18 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1994
* Andrew Cagney. All rights reserved.
@@ -44,6 +44,29 @@
#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
+
+
#define _CONCAT(x,y) x##y
#define PSEUDO_PREFIX(p,x,y) .extern _ASM_LABEL(___cerror) ; \
ENTRY(p##x) \
diff --git a/lib/libc/arch/powerpc/string/memmove.S b/lib/libc/arch/powerpc/string/memmove.S
index 875c562b0b2..80aca10ce78 100644
--- a/lib/libc/arch/powerpc/string/memmove.S
+++ b/lib/libc/arch/powerpc/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.1 2014/12/04 12:10:26 deraadt Exp $ */
+/* $OpenBSD: memmove.S,v 1.2 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: memmove.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */
/* stropt/memmove.S, pl_string_common, pl_linux 10/11/04 11:45:37
@@ -39,7 +39,7 @@
* ==========================================================================
*/
-#include <machine/asm.h>
+#include "SYS.h"
.text
@@ -166,3 +166,5 @@ rlast2:
bdnz+ rlast2 /* Dec ctr, and branch if more */
/* bytes left */
blr
+END_STRONG(memmove)
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/sh/SYS.h b/lib/libc/arch/sh/SYS.h
index 468e265c947..ac7991f7cd3 100644
--- a/lib/libc/arch/sh/SYS.h
+++ b/lib/libc/arch/sh/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.6 2015/04/07 01:27:06 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -37,6 +37,31 @@
#include <machine/asm.h>
#include <sys/syscall.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) SET_ENTRY_SIZE(x); \
+ _HIDDEN_FALIAS(x,x); \
+ SET_ENTRY_SIZE(_HIDDEN(x))
+#define END_WEAK(x) END_STRONG(x); .weak x
+
+
#define SYSENTRY(x) \
WEAK_ALIAS(x,_thread_sys_ ## x); \
ENTRY(_thread_sys_ ## x)
diff --git a/lib/libc/arch/sh/string/bcopy.S b/lib/libc/arch/sh/string/bcopy.S
index 533583d9792..473bc429bbe 100644
--- a/lib/libc/arch/sh/string/bcopy.S
+++ b/lib/libc/arch/sh/string/bcopy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.S,v 1.2 2014/11/30 19:43:56 deraadt Exp $ */
+/* $OpenBSD: bcopy.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: memcpy.S,v 1.2 2006/04/22 23:53:47 uwe Exp $ */
/*
@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define REG_SRC r4
#define REG_DST r5
@@ -238,3 +238,4 @@ ov_no_align_delay:
9:
rts
nop
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/sh/string/ffs.S b/lib/libc/arch/sh/string/ffs.S
index 7e0dd7e2834..0a639c79211 100644
--- a/lib/libc/arch/sh/string/ffs.S
+++ b/lib/libc/arch/sh/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.2 2008/06/26 05:42:05 ray Exp $ */
+/* $OpenBSD: ffs.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*-
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* ffs - find first bit set
@@ -91,3 +91,4 @@ L8bit:
Lzero: rts
nop
+END_WEAK(ffs)
diff --git a/lib/libc/arch/sh/string/memcpy.S b/lib/libc/arch/sh/string/memcpy.S
index f12004e1edd..ed266caa71c 100644
--- a/lib/libc/arch/sh/string/memcpy.S
+++ b/lib/libc/arch/sh/string/memcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcpy.S,v 1.2 2014/11/30 19:43:56 deraadt Exp $ */
+/* $OpenBSD: memcpy.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: memcpy.S,v 1.2 2006/04/22 23:53:47 uwe Exp $ */
/*
@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define REG_DST0 r3
#define REG_SRC r5
@@ -137,3 +137,4 @@ no_align_delay:
bcopy_return:
rts
mov REG_DST0,r0
+END_STRONG(memcpy)
diff --git a/lib/libc/arch/sh/string/memmove.S b/lib/libc/arch/sh/string/memmove.S
index 3a570c62355..131be417efc 100644
--- a/lib/libc/arch/sh/string/memmove.S
+++ b/lib/libc/arch/sh/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.2 2014/11/30 19:43:56 deraadt Exp $ */
+/* $OpenBSD: memmove.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: memcpy.S,v 1.2 2006/04/22 23:53:47 uwe Exp $ */
/*
@@ -28,7 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define REG_DST0 r3
#define REG_SRC r5
@@ -239,3 +239,4 @@ ov_no_align_delay:
9:
rts
mov REG_DST0,r0
+END_STRONG(memmove)
diff --git a/lib/libc/arch/sh/string/memset.S b/lib/libc/arch/sh/string/memset.S
index 2ed22197ce8..f82f4a4ecfb 100644
--- a/lib/libc/arch/sh/string/memset.S
+++ b/lib/libc/arch/sh/string/memset.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memset.S,v 1.1 2006/10/10 22:07:10 miod Exp $ */
+/* $OpenBSD: memset.S,v 1.2 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*-
@@ -27,7 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
#define REG_PTR r0
#define REG_TMP1 r1
@@ -293,3 +293,8 @@ unaligned_len:
bra aligned
sub REG_DST,REG_LEN
+#ifdef BZERO
+END_WEAK(bzero)
+#else
+END_STRONG(memset)
+#endif
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)
diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h
index 3f934da0323..6b2897480dd 100644
--- a/lib/libc/arch/sparc64/SYS.h
+++ b/lib/libc/arch/sparc64/SYS.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SYS.h,v 1.12 2015/04/07 01:27:07 guenther Exp $ */
+/* $OpenBSD: SYS.h,v 1.13 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -46,6 +46,30 @@
#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
+
+
/*
* ERROR branches to cerror. This is done with a macro so that I can
* change it to be position independent later, if need be.
diff --git a/lib/libc/arch/sparc64/string/ffs.S b/lib/libc/arch/sparc64/string/ffs.S
index ee55fdab384..7fd91f871b6 100644
--- a/lib/libc/arch/sparc64/string/ffs.S
+++ b/lib/libc/arch/sparc64/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.4 2012/08/22 17:19:35 pascal Exp $ */
+/* $OpenBSD: ffs.S,v 1.5 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
/*
* ffs returns the number of the rightmost bit set in its argument,
* i.e., the lowest value such that (x & (ffs(x) - 1)) is nonzero.
@@ -83,6 +83,7 @@ ENTRY(ffs)
ldsb [%o2 + %o0], %o0
retl
add %o0, 24, %o0
+END_WEAK(ffs)
_C_LABEL(__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/sparc64/string/strlen.S b/lib/libc/arch/sparc64/string/strlen.S
index 08082ef8d58..8ef36a19870 100644
--- a/lib/libc/arch/sparc64/string/strlen.S
+++ b/lib/libc/arch/sparc64/string/strlen.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.S,v 1.2 2003/06/02 20:18:33 millert Exp $ */
+/* $OpenBSD: strlen.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/* $NetBSD: strlen.S,v 1.1 1998/09/11 04:56:33 eeh Exp $ */
/*
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "SYS.h"
ENTRY(strlen)
add %o0, 1, %o1 ! save starting point + 1
@@ -44,3 +44,4 @@ ENTRY(strlen)
inc %o0 ! always increment pointer
retl
sub %o0, %o1, %o0 ! return length (ptr - (origptr+1))
+END_STRONG(strlen)
diff --git a/lib/libc/arch/vax/DEFS.h b/lib/libc/arch/vax/DEFS.h
index 415e86df113..13e0859dfa6 100644
--- a/lib/libc/arch/vax/DEFS.h
+++ b/lib/libc/arch/vax/DEFS.h
@@ -1,4 +1,27 @@
-/* $OpenBSD: DEFS.h,v 1.4 1996/08/19 08:18:17 tholo Exp $ */
+/* $OpenBSD: DEFS.h,v 1.5 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/vax/SYS.h b/lib/libc/arch/vax/SYS.h
index 2449243f186..cba02a0678a 100644
--- a/lib/libc/arch/vax/SYS.h
+++ b/lib/libc/arch/vax/SYS.h
@@ -1,4 +1,4 @@
-/* $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 $ */
/* $NetBSD: SYS.h,v 1.4 1997/05/02 18:15:32 kleink Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <machine/asm.h>
+#include "DEFS.h"
#include <sys/syscall.h>
#define _CAT(x,y) x##y
diff --git a/lib/libc/arch/vax/string/bcmp.S b/lib/libc/arch/vax/string/bcmp.S
index ccb63da20f2..c25d46c5102 100644
--- a/lib/libc/arch/vax/string/bcmp.S
+++ b/lib/libc/arch/vax/string/bcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcmp.S,v 1.5 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: bcmp.S,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -54,3 +54,4 @@ ENTRY(bcmp, 0)
clrl %r0 # we have a match!
9:
ret
+END_WEAK(bcmp)
diff --git a/lib/libc/arch/vax/string/bcopy.S b/lib/libc/arch/vax/string/bcopy.S
index 5af2edea373..27d5d8fd24a 100644
--- a/lib/libc/arch/vax/string/bcopy.S
+++ b/lib/libc/arch/vax/string/bcopy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.S,v 1.6 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: bcopy.S,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -69,3 +69,4 @@ ENTRY(bcopy, R2|R3|R4|R5|R6)
subl2 %r6,%r3
movc3 %r6,(%r1),(%r3)
ret
+END_WEAK(bcopy)
diff --git a/lib/libc/arch/vax/string/bzero.S b/lib/libc/arch/vax/string/bzero.S
index 55febbe11b5..0867d3971c3 100644
--- a/lib/libc/arch/vax/string/bzero.S
+++ b/lib/libc/arch/vax/string/bzero.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bzero.S,v 1.6 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: bzero.S,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -44,3 +44,4 @@ ENTRY(bzero, R2|R3|R4|R5)
jgtr 1b
movc5 $0,(%r3),$0,8(%ap),(%r3)
ret
+END_WEAK(bzero)
diff --git a/lib/libc/arch/vax/string/ffs.S b/lib/libc/arch/vax/string/ffs.S
index e2caa68c607..1e75f128a06 100644
--- a/lib/libc/arch/vax/string/ffs.S
+++ b/lib/libc/arch/vax/string/ffs.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.S,v 1.5 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: ffs.S,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,3 +39,4 @@ ENTRY(ffs, 0)
1:
incl %r0
ret
+END_WEAK(ffs)
diff --git a/lib/libc/arch/vax/string/memcmp.S b/lib/libc/arch/vax/string/memcmp.S
index 6a794547d5d..8fdf29435bb 100644
--- a/lib/libc/arch/vax/string/memcmp.S
+++ b/lib/libc/arch/vax/string/memcmp.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcmp.S,v 1.5 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: memcmp.S,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -63,3 +63,4 @@ ENTRY(memcmp, 0)
subl3 %r4,%r3,%r0
9:
ret
+END_STRONG(memcmp)
diff --git a/lib/libc/arch/vax/string/memcpy.S b/lib/libc/arch/vax/string/memcpy.S
index d456a9a2d4f..e13ae0baa24 100644
--- a/lib/libc/arch/vax/string/memcpy.S
+++ b/lib/libc/arch/vax/string/memcpy.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcpy.S,v 1.8 2015/05/26 20:23:39 miod Exp $ */
+/* $OpenBSD: memcpy.S,v 1.9 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -56,3 +56,4 @@ ENTRY(memcpy, R2|R3|R4|R5)
movl 12(%ap),%r2
decw %r0 /* from 0 to 65535 */
brb 1b /* retry */
+END_STRONG(memcpy)
diff --git a/lib/libc/arch/vax/string/memmove.S b/lib/libc/arch/vax/string/memmove.S
index 86513fdbba9..3f71d2629c1 100644
--- a/lib/libc/arch/vax/string/memmove.S
+++ b/lib/libc/arch/vax/string/memmove.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memmove.S,v 1.6 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: memmove.S,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -84,3 +84,4 @@ ENTRY(memmove, R2|R3|R4|R5)
subl2 %r0,%r1
subl2 %r0,%r3
brb 5b
+END_STRONG(memmove)
diff --git a/lib/libc/arch/vax/string/memset.S b/lib/libc/arch/vax/string/memset.S
index b861477884f..40bada34ea7 100644
--- a/lib/libc/arch/vax/string/memset.S
+++ b/lib/libc/arch/vax/string/memset.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: memset.S,v 1.6 2013/07/05 21:10:50 miod Exp $ */
+/* $OpenBSD: memset.S,v 1.7 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -46,3 +46,4 @@ ENTRY(memset, R2|R3|R4|R5)
subl2 %r0,12(%ap)
movc5 $0,(%r3),%r1,%r0,(%r3)
jbr 1b
+END_STRONG(memset)
diff --git a/lib/libc/arch/vax/string/strchr.S b/lib/libc/arch/vax/string/strchr.S
index 9d1b75423e7..7c8b8de57dd 100644
--- a/lib/libc/arch/vax/string/strchr.S
+++ b/lib/libc/arch/vax/string/strchr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */
+/* $OpenBSD: strchr.S,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -56,3 +56,4 @@ ENTRY(strchr, 0)
jneq 3b
decl %r0
jbr 2b
+END_STRONG(strchr)