summaryrefslogtreecommitdiff
path: root/lib/libc/arch/arm
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-08-31 02:53:58 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-08-31 02:53:58 +0000
commita4c7e44b581895df2d4b7cc4f88e39b12a83c740 (patch)
tree0990e8c4dea4839a061c02403f3b3bb05884c4de /lib/libc/arch/arm
parent105db1ed9f850ad922a57ad78b72b1919c986e21 (diff)
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/arm')
-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
11 files changed, 55 insertions, 21 deletions
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)