Merge "Minor linker cleanup, primarily to use Elf32_Dyn"
diff --git a/libc/Android.mk b/libc/Android.mk
index a8b4ebd..884d759 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -111,35 +111,8 @@
 	string/strspn.c \
 	string/strstr.c \
 	string/strtok.c \
-	wchar/wcpcpy.c \
-	wchar/wcpncpy.c \
-	wchar/wcscasecmp.c \
-	wchar/wcscat.c \
-	wchar/wcschr.c \
-	wchar/wcscmp.c \
-	wchar/wcscpy.c \
-	wchar/wcscspn.c \
-	wchar/wcsdup.c \
-	wchar/wcslcat.c \
-	wchar/wcslcpy.c \
-	wchar/wcslen.c \
-	wchar/wcsncasecmp.c \
-	wchar/wcsncat.c \
-	wchar/wcsncmp.c \
-	wchar/wcsncpy.c \
-	wchar/wcsnlen.c \
-	wchar/wcspbrk.c \
-	wchar/wcsrchr.c \
-	wchar/wcsspn.c \
-	wchar/wcsstr.c \
-	wchar/wcstok.c \
 	wchar/wcswidth.c \
 	wchar/wcsxfrm.c \
-	wchar/wmemchr.c \
-	wchar/wmemcmp.c \
-	wchar/wmemcpy.c \
-	wchar/wmemmove.c \
-	wchar/wmemset.c \
 	tzcode/asctime.c \
 	tzcode/difftime.c \
 	tzcode/localtime.c \
@@ -318,6 +291,33 @@
 
 libc_upstream_freebsd_src_files := \
     upstream-freebsd/lib/libc/stdlib/realpath.c \
+    upstream-freebsd/lib/libc/string/wcpcpy.c \
+    upstream-freebsd/lib/libc/string/wcpncpy.c \
+    upstream-freebsd/lib/libc/string/wcscasecmp.c \
+    upstream-freebsd/lib/libc/string/wcscat.c \
+    upstream-freebsd/lib/libc/string/wcschr.c \
+    upstream-freebsd/lib/libc/string/wcscmp.c \
+    upstream-freebsd/lib/libc/string/wcscpy.c \
+    upstream-freebsd/lib/libc/string/wcscspn.c \
+    upstream-freebsd/lib/libc/string/wcsdup.c \
+    upstream-freebsd/lib/libc/string/wcslcat.c \
+    upstream-freebsd/lib/libc/string/wcslcpy.c \
+    upstream-freebsd/lib/libc/string/wcslen.c \
+    upstream-freebsd/lib/libc/string/wcsncasecmp.c \
+    upstream-freebsd/lib/libc/string/wcsncat.c \
+    upstream-freebsd/lib/libc/string/wcsncmp.c \
+    upstream-freebsd/lib/libc/string/wcsncpy.c \
+    upstream-freebsd/lib/libc/string/wcsnlen.c \
+    upstream-freebsd/lib/libc/string/wcspbrk.c \
+    upstream-freebsd/lib/libc/string/wcsrchr.c \
+    upstream-freebsd/lib/libc/string/wcsspn.c \
+    upstream-freebsd/lib/libc/string/wcsstr.c \
+    upstream-freebsd/lib/libc/string/wcstok.c \
+    upstream-freebsd/lib/libc/string/wmemchr.c \
+    upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-freebsd/lib/libc/string/wmemcpy.c \
+    upstream-freebsd/lib/libc/string/wmemmove.c \
+    upstream-freebsd/lib/libc/string/wmemset.c \
 
 libc_upstream_netbsd_src_files := \
     upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
diff --git a/libc/arch-arm/bionic/memcpy.a15.S b/libc/arch-arm/bionic/memcpy.a15.S
index d1bfb7c..516e20c 100644
--- a/libc/arch-arm/bionic/memcpy.a15.S
+++ b/libc/arch-arm/bionic/memcpy.a15.S
@@ -26,12 +26,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
-     (!(defined (__ARM_ARCH_7A__))))
-
-        /* Do nothing here. See memcpy-stub.c in the same directory. */
-
-#else
     /* Prototype: void *memcpy (void *dst, const void *src, size_t count).  */
 
         /* Use the version of memcpy implemented using LDRD and STRD.
@@ -50,16 +44,12 @@
        destination register must be even and the second consecutive in
        ARM state, but not in Thumb state.  */
 
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
         .syntax         unified
 
-#if defined (__thumb__)
-        .thumb
-        .thumb_func
-#endif
-
-        .global memcpy
-        .type   memcpy, %function
-memcpy:
+ENTRY(memcpy)
 
        /* Assumes that n >= 0, and dst, src are valid pointers.
           If there is at least 8 bytes to copy, use LDRD/STRD.
@@ -69,12 +59,16 @@
           When less than 8 left, copy a word and then byte by byte.  */
 
        /* Save registers (r0 holds the return value):
-          optimized push {r0, r4, r5, lr}.
+          optimized push {r0, r4, r5, r6, r7, lr}.
           To try and improve performance, stack layout changed,
           i.e., not keeping the stack looking like users expect
           (highest numbered register at highest address).  */
-        push {r0, lr}
-        strd r4, r5, [sp, #-8]!
+        .save   {r0, lr}
+        push    {r0, lr}
+        .save   {r4, r5}
+        strd    r4, r5, [sp, #-8]!
+        .save   {r6, r7}
+        strd    r6, r7, [sp, #-8]!
 
        /* TODO: Add debug frame directives.
           We don't need exception unwind directives, because the code below
@@ -194,9 +188,11 @@
         strbcs  r5, [r0]
 
 return:
-        /* Restore registers: optimized pop {r0, r4, r5, pc}   */
+        /* Restore registers: optimized pop {r0, r4, r5, r6, r7, pc}   */
+        /* This is the only return point of memcpy.  */
+        ldrd r6, r7, [sp], #8
         ldrd r4, r5, [sp], #8
-        pop {r0, pc}           /* This is the only return point of memcpy.  */
+        pop {r0, pc}
 
 #ifndef __ARM_FEATURE_UNALIGNED
 
@@ -223,12 +219,6 @@
        /* Get here if there is more than 8 bytes to copy.
           The number of bytes to copy is r2+8, r2 >= 0.  */
 
-       /* Save registers: push { r6, r7 }.
-          We need additional registers for LDRD and STRD, because in ARM state
-          the first destination register must be even and the second
-      consecutive.  */
-       strd     r6, r7, [sp, #-8]!
-
        subs     r2, r2, #56
        blt      4f         /* Go to misaligned copy of less than 64 bytes.  */
 
@@ -259,10 +249,6 @@
        /* Restore the count if there is more than 7 bytes to copy.  */
         adds    r2, r2, #56
 
-       /* If less than 8 bytes to copy,
-          restore registers saved for this loop: optimized poplt { r6, r7 }. */
-        itt     lt
-        ldrdlt  r6, r7, [sp], #8
         blt     6f          /* Go to misaligned copy of less than 8 bytes.  */
 
 5:
@@ -278,9 +264,6 @@
         subs    r2, r2, #8
         bge     5b                        /* If there is more to copy.  */
 
-        /* Restore registers saved for this loop: optimized pop { r6, r7 }.  */
-        ldrd    r6, r7, [sp], #8
-
 6:
         /* Get here if there less than 8 bytes to copy (-8 <= r2 < 0)
            and they are misaligned.  */
@@ -420,4 +403,4 @@
 
 #endif  /* not __ARM_FEATURE_UNALIGNED  */
 
-#endif  /* memcpy */
+END(memcpy)
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index ef88e04..a4e19f0 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -149,6 +149,11 @@
 extern wint_t		 towctrans(wint_t, wctrans_t);
 extern wctrans_t	 wctrans (const char *);
 
+#if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
+wchar_t* wcsdup(const wchar_t*);
+size_t wcsnlen(const wchar_t*, size_t);
+#endif
+
 __END_DECLS
 
 #endif /* _WCHAR_H_ */
diff --git a/libc/wchar/wcpcpy.c b/libc/upstream-freebsd/lib/libc/string/wcpcpy.c
similarity index 100%
rename from libc/wchar/wcpcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcpcpy.c
diff --git a/libc/wchar/wcpncpy.c b/libc/upstream-freebsd/lib/libc/string/wcpncpy.c
similarity index 100%
rename from libc/wchar/wcpncpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcpncpy.c
diff --git a/libc/wchar/wcscasecmp.c b/libc/upstream-freebsd/lib/libc/string/wcscasecmp.c
similarity index 100%
rename from libc/wchar/wcscasecmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcscasecmp.c
diff --git a/libc/wchar/wcscat.c b/libc/upstream-freebsd/lib/libc/string/wcscat.c
similarity index 100%
rename from libc/wchar/wcscat.c
rename to libc/upstream-freebsd/lib/libc/string/wcscat.c
diff --git a/libc/wchar/wcschr.c b/libc/upstream-freebsd/lib/libc/string/wcschr.c
similarity index 100%
rename from libc/wchar/wcschr.c
rename to libc/upstream-freebsd/lib/libc/string/wcschr.c
diff --git a/libc/wchar/wcscmp.c b/libc/upstream-freebsd/lib/libc/string/wcscmp.c
similarity index 100%
rename from libc/wchar/wcscmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcscmp.c
diff --git a/libc/wchar/wcscpy.c b/libc/upstream-freebsd/lib/libc/string/wcscpy.c
similarity index 100%
rename from libc/wchar/wcscpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcscpy.c
diff --git a/libc/wchar/wcscspn.c b/libc/upstream-freebsd/lib/libc/string/wcscspn.c
similarity index 100%
rename from libc/wchar/wcscspn.c
rename to libc/upstream-freebsd/lib/libc/string/wcscspn.c
diff --git a/libc/wchar/wcsdup.c b/libc/upstream-freebsd/lib/libc/string/wcsdup.c
similarity index 100%
rename from libc/wchar/wcsdup.c
rename to libc/upstream-freebsd/lib/libc/string/wcsdup.c
diff --git a/libc/wchar/wcslcat.c b/libc/upstream-freebsd/lib/libc/string/wcslcat.c
similarity index 100%
rename from libc/wchar/wcslcat.c
rename to libc/upstream-freebsd/lib/libc/string/wcslcat.c
diff --git a/libc/wchar/wcslcpy.c b/libc/upstream-freebsd/lib/libc/string/wcslcpy.c
similarity index 100%
rename from libc/wchar/wcslcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcslcpy.c
diff --git a/libc/wchar/wcslen.c b/libc/upstream-freebsd/lib/libc/string/wcslen.c
similarity index 100%
rename from libc/wchar/wcslen.c
rename to libc/upstream-freebsd/lib/libc/string/wcslen.c
diff --git a/libc/wchar/wcsncasecmp.c b/libc/upstream-freebsd/lib/libc/string/wcsncasecmp.c
similarity index 100%
rename from libc/wchar/wcsncasecmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncasecmp.c
diff --git a/libc/wchar/wcsncat.c b/libc/upstream-freebsd/lib/libc/string/wcsncat.c
similarity index 100%
rename from libc/wchar/wcsncat.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncat.c
diff --git a/libc/wchar/wcsncmp.c b/libc/upstream-freebsd/lib/libc/string/wcsncmp.c
similarity index 100%
rename from libc/wchar/wcsncmp.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncmp.c
diff --git a/libc/wchar/wcsncpy.c b/libc/upstream-freebsd/lib/libc/string/wcsncpy.c
similarity index 100%
rename from libc/wchar/wcsncpy.c
rename to libc/upstream-freebsd/lib/libc/string/wcsncpy.c
diff --git a/libc/wchar/wcsnlen.c b/libc/upstream-freebsd/lib/libc/string/wcsnlen.c
similarity index 100%
rename from libc/wchar/wcsnlen.c
rename to libc/upstream-freebsd/lib/libc/string/wcsnlen.c
diff --git a/libc/wchar/wcspbrk.c b/libc/upstream-freebsd/lib/libc/string/wcspbrk.c
similarity index 100%
rename from libc/wchar/wcspbrk.c
rename to libc/upstream-freebsd/lib/libc/string/wcspbrk.c
diff --git a/libc/wchar/wcsrchr.c b/libc/upstream-freebsd/lib/libc/string/wcsrchr.c
similarity index 100%
rename from libc/wchar/wcsrchr.c
rename to libc/upstream-freebsd/lib/libc/string/wcsrchr.c
diff --git a/libc/wchar/wcsspn.c b/libc/upstream-freebsd/lib/libc/string/wcsspn.c
similarity index 100%
rename from libc/wchar/wcsspn.c
rename to libc/upstream-freebsd/lib/libc/string/wcsspn.c
diff --git a/libc/wchar/wcsstr.c b/libc/upstream-freebsd/lib/libc/string/wcsstr.c
similarity index 100%
rename from libc/wchar/wcsstr.c
rename to libc/upstream-freebsd/lib/libc/string/wcsstr.c
diff --git a/libc/wchar/wcstok.c b/libc/upstream-freebsd/lib/libc/string/wcstok.c
similarity index 100%
rename from libc/wchar/wcstok.c
rename to libc/upstream-freebsd/lib/libc/string/wcstok.c
diff --git a/libc/wchar/wmemchr.c b/libc/upstream-freebsd/lib/libc/string/wmemchr.c
similarity index 100%
rename from libc/wchar/wmemchr.c
rename to libc/upstream-freebsd/lib/libc/string/wmemchr.c
diff --git a/libc/wchar/wmemcmp.c b/libc/upstream-freebsd/lib/libc/string/wmemcmp.c
similarity index 100%
rename from libc/wchar/wmemcmp.c
rename to libc/upstream-freebsd/lib/libc/string/wmemcmp.c
diff --git a/libc/wchar/wmemcpy.c b/libc/upstream-freebsd/lib/libc/string/wmemcpy.c
similarity index 100%
rename from libc/wchar/wmemcpy.c
rename to libc/upstream-freebsd/lib/libc/string/wmemcpy.c
diff --git a/libc/wchar/wmemmove.c b/libc/upstream-freebsd/lib/libc/string/wmemmove.c
similarity index 100%
rename from libc/wchar/wmemmove.c
rename to libc/upstream-freebsd/lib/libc/string/wmemmove.c
diff --git a/libc/wchar/wmemset.c b/libc/upstream-freebsd/lib/libc/string/wmemset.c
similarity index 100%
rename from libc/wchar/wmemset.c
rename to libc/upstream-freebsd/lib/libc/string/wmemset.c
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
index 019650e..bd59e05 100644
--- a/libc/zoneinfo/tzdata
+++ b/libc/zoneinfo/tzdata
Binary files differ