summaryrefslogtreecommitdiff
path: root/lib/libc/arch/i386
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch/i386')
-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
14 files changed, 63 insertions, 27 deletions
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)