Merge "Deprecate bzero"
diff --git a/libc/Android.bp b/libc/Android.bp
index 74fd22b..d355d4c 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1348,6 +1348,7 @@
         "bionic/getpid.cpp",
         "bionic/gettid.cpp",
         "bionic/__gnu_basename.cpp",
+        "bionic/ifaddrs.cpp",
         "bionic/inotify_init.cpp",
         "bionic/ioctl.cpp",
         "bionic/lchown.cpp",
@@ -1766,7 +1767,6 @@
 
     nocrt: true,
 
-    // special for arm
     arch: {
         arm: {
             //TODO: This is to work around b/24465209. Remove after root cause is fixed
@@ -1774,6 +1774,11 @@
 
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.arm.map",
+            product_variables: {
+                brillo: {
+                    version_script: "libc.arm.brillo.map",
+                },
+            },
 
             shared: {
                 srcs: ["arch-arm/bionic/exidx_dynamic.c"],
@@ -1781,6 +1786,8 @@
             static: {
                 srcs: ["arch-arm/bionic/exidx_static.c"],
             },
+
+            // special for arm
             cflags: ["-DCRT_LEGACY_WORKAROUND"],
             srcs: [
                 "arch-arm/bionic/atexit_legacy.c",
@@ -1793,6 +1800,11 @@
         mips: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.mips.map",
+            product_variables: {
+                brillo: {
+                    version_script: "libc.mips.brillo.map",
+                },
+            },
         },
         mips64: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
@@ -1804,6 +1816,11 @@
 
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.x86.map",
+            product_variables: {
+                brillo: {
+                    version_script: "libc.x86.brillo.map",
+                },
+            },
         },
         x86_64: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
diff --git a/libc/arch-arm/bionic/__aeabi.c b/libc/arch-arm/bionic/__aeabi.c
index 254c7a6..e4c85d9 100644
--- a/libc/arch-arm/bionic/__aeabi.c
+++ b/libc/arch-arm/bionic/__aeabi.c
@@ -51,34 +51,34 @@
  */
 
 int __attribute__((weak))
-__aeabi_atexit(void *object, void (*destructor) (void *), void *dso_handle) {
+__aeabi_atexit_impl(void *object, void (*destructor) (void *), void *dso_handle) {
     return __cxa_atexit(destructor, object, dso_handle);
 }
 
 
 void __attribute__((weak))
-__aeabi_memcpy8(void *dest, const void *src, size_t n) {
+__aeabi_memcpy8_impl(void *dest, const void *src, size_t n) {
     memcpy(dest, src, n);
 }
 
-void __attribute__((weak)) __aeabi_memcpy4(void *dest, const void *src, size_t n) {
+void __attribute__((weak)) __aeabi_memcpy4_impl(void *dest, const void *src, size_t n) {
     memcpy(dest, src, n);
 }
 
-void __attribute__((weak)) __aeabi_memcpy(void *dest, const void *src, size_t n) {
+void __attribute__((weak)) __aeabi_memcpy_impl(void *dest, const void *src, size_t n) {
     memcpy(dest, src, n);
 }
 
 
-void __attribute__((weak)) __aeabi_memmove8(void *dest, const void *src, size_t n) {
+void __attribute__((weak)) __aeabi_memmove8_impl(void *dest, const void *src, size_t n) {
     memmove(dest, src, n);
 }
 
-void __attribute__((weak)) __aeabi_memmove4(void *dest, const void *src, size_t n) {
+void __attribute__((weak)) __aeabi_memmove4_impl(void *dest, const void *src, size_t n) {
     memmove(dest, src, n);
 }
 
-void __attribute__((weak)) __aeabi_memmove(void *dest, const void *src, size_t n) {
+void __attribute__((weak)) __aeabi_memmove_impl(void *dest, const void *src, size_t n) {
     memmove(dest, src, n);
 }
 
@@ -87,27 +87,47 @@
  *  This allows __aeabi_memclr to tail-call __aeabi_memset
  */
 
-void __attribute__((weak)) __aeabi_memset8(void *dest, size_t n, int c) {
+void __attribute__((weak)) __aeabi_memset8_impl(void *dest, size_t n, int c) {
     memset(dest, c, n);
 }
 
-void __attribute__((weak)) __aeabi_memset4(void *dest, size_t n, int c) {
+void __attribute__((weak)) __aeabi_memset4_impl(void *dest, size_t n, int c) {
     memset(dest, c, n);
 }
 
-void __attribute__((weak)) __aeabi_memset(void *dest, size_t n, int c) {
+void __attribute__((weak)) __aeabi_memset_impl(void *dest, size_t n, int c) {
     memset(dest, c, n);
 }
 
 
-void __attribute__((weak)) __aeabi_memclr8(void *dest, size_t n) {
-    __aeabi_memset8(dest, n, 0);
+void __attribute__((weak)) __aeabi_memclr8_impl(void *dest, size_t n) {
+    __aeabi_memset8_impl(dest, n, 0);
 }
 
-void __attribute__((weak)) __aeabi_memclr4(void *dest, size_t n) {
-    __aeabi_memset4(dest, n, 0);
+void __attribute__((weak)) __aeabi_memclr4_impl(void *dest, size_t n) {
+    __aeabi_memset4_impl(dest, n, 0);
 }
 
-void __attribute__((weak)) __aeabi_memclr(void *dest, size_t n) {
-    __aeabi_memset(dest, n, 0);
+void __attribute__((weak)) __aeabi_memclr_impl(void *dest, size_t n) {
+    __aeabi_memset_impl(dest, n, 0);
 }
+
+#define __AEABI_SYMVERS(fn_name) \
+__asm__(".symver " #fn_name "_impl, " #fn_name "@@LIBC"); \
+__asm__(".symver " #fn_name "_impl, " #fn_name "@LIBC_PRIVATE")
+
+__AEABI_SYMVERS(__aeabi_atexit);
+__AEABI_SYMVERS(__aeabi_memcpy8);
+__AEABI_SYMVERS(__aeabi_memcpy4);
+__AEABI_SYMVERS(__aeabi_memcpy);
+__AEABI_SYMVERS(__aeabi_memmove8);
+__AEABI_SYMVERS(__aeabi_memmove4);
+__AEABI_SYMVERS(__aeabi_memmove);
+__AEABI_SYMVERS(__aeabi_memset8);
+__AEABI_SYMVERS(__aeabi_memset4);
+__AEABI_SYMVERS(__aeabi_memset);
+__AEABI_SYMVERS(__aeabi_memclr8);
+__AEABI_SYMVERS(__aeabi_memclr4);
+__AEABI_SYMVERS(__aeabi_memclr);
+
+#undef __AEABI_SYMVERS
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index b0c62d6..d16b452 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -336,7 +336,7 @@
 
   if (getauxval(AT_SECURE)) {
     // If this is a setuid/setgid program, close the security hole described in
-    // ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/FreeBSD-SA-02:23.stdio.asc
+    // https://www.freebsd.org/security/advisories/FreeBSD-SA-02:23.stdio.asc
     __nullify_closed_stdio();
 
     __sanitize_environment_variables(args.envp);
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 2720455..28cce40 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -826,6 +826,10 @@
 }
 
 static prop_area* get_prop_area_for_name(const char* name) {
+    if (strncmp(name, "ro.", 3) == 0) {
+        name += 3;
+    }
+
     auto entry = list_find(prefixes, [name](prefix_node* l) {
         return l->prefix[0] == '*' || !strncmp(l->prefix, name, l->prefix_len);
     });
diff --git a/libc/libc.arm.brillo.map b/libc/libc.arm.brillo.map
index 7969331..317b3b2 100644
--- a/libc/libc.arm.brillo.map
+++ b/libc/libc.arm.brillo.map
@@ -1268,6 +1268,7 @@
     __accept4; # arm x86 mips
     __adddf3; # arm
     __addsf3; # arm
+    __aeabi_atexit; # arm
     __aeabi_cdcmpeq; # arm
     __aeabi_cdcmple; # arm
     __aeabi_cdrcmple; # arm
@@ -1306,6 +1307,18 @@
     __aeabi_llsl; # arm
     __aeabi_llsr; # arm
     __aeabi_lmul; # arm
+    __aeabi_memclr; # arm
+    __aeabi_memclr4; # arm
+    __aeabi_memclr8; # arm
+    __aeabi_memcpy; # arm
+    __aeabi_memcpy4; # arm
+    __aeabi_memcpy8; # arm
+    __aeabi_memmove; # arm
+    __aeabi_memmove4; # arm
+    __aeabi_memmove8; # arm
+    __aeabi_memset; # arm
+    __aeabi_memset4; # arm
+    __aeabi_memset8; # arm
     __aeabi_ui2d; # arm
     __aeabi_ui2f; # arm
     __aeabi_uidiv; # arm
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index c9d9fe8..efd1106 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1269,6 +1269,7 @@
     __accept4; # arm x86 mips
     __adddf3; # arm
     __addsf3; # arm
+    __aeabi_atexit; # arm
     __aeabi_cdcmpeq; # arm
     __aeabi_cdcmple; # arm
     __aeabi_cdrcmple; # arm
@@ -1307,6 +1308,18 @@
     __aeabi_llsl; # arm
     __aeabi_llsr; # arm
     __aeabi_lmul; # arm
+    __aeabi_memclr; # arm
+    __aeabi_memclr4; # arm
+    __aeabi_memclr8; # arm
+    __aeabi_memcpy; # arm
+    __aeabi_memcpy4; # arm
+    __aeabi_memcpy8; # arm
+    __aeabi_memmove; # arm
+    __aeabi_memmove4; # arm
+    __aeabi_memmove8; # arm
+    __aeabi_memset; # arm
+    __aeabi_memset4; # arm
+    __aeabi_memset8; # arm
     __aeabi_ui2d; # arm
     __aeabi_ui2f; # arm
     __aeabi_uidiv; # arm
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 87393ee..d2e2b1b 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1295,6 +1295,7 @@
     __accept4; # arm x86 mips
     __adddf3; # arm
     __addsf3; # arm
+    __aeabi_atexit; # arm
     __aeabi_cdcmpeq; # arm
     __aeabi_cdcmple; # arm
     __aeabi_cdrcmple; # arm
@@ -1333,6 +1334,18 @@
     __aeabi_llsl; # arm
     __aeabi_llsr; # arm
     __aeabi_lmul; # arm
+    __aeabi_memclr; # arm
+    __aeabi_memclr4; # arm
+    __aeabi_memclr8; # arm
+    __aeabi_memcpy; # arm
+    __aeabi_memcpy4; # arm
+    __aeabi_memcpy8; # arm
+    __aeabi_memmove; # arm
+    __aeabi_memmove4; # arm
+    __aeabi_memmove8; # arm
+    __aeabi_memset; # arm
+    __aeabi_memset4; # arm
+    __aeabi_memset8; # arm
     __aeabi_ui2d; # arm
     __aeabi_ui2f; # arm
     __aeabi_uidiv; # arm
diff --git a/libc/private/KernelArgumentBlock.h b/libc/private/KernelArgumentBlock.h
index c8ea497..68d4999 100644
--- a/libc/private/KernelArgumentBlock.h
+++ b/libc/private/KernelArgumentBlock.h
@@ -38,32 +38,25 @@
     argv = reinterpret_cast<char**>(args + 1);
     envp = argv + argc + 1;
 
-    // Skip over all environment variable definitions to find aux vector.
-    // The end of the environment block is marked by two NULL pointers.
+    // Skip over all environment variable definitions to find the aux vector.
+    // The end of the environment block is marked by a NULL pointer.
     char** p = envp;
     while (*p != NULL) {
       ++p;
     }
-    ++p; // Skip second NULL;
+    ++p; // Skip the NULL itself.
 
     auxv = reinterpret_cast<ElfW(auxv_t)*>(p);
   }
 
   // Similar to ::getauxval but doesn't require the libc global variables to be set up,
-  // so it's safe to call this really early on. This function also lets you distinguish
-  // between the inability to find the given type and its value just happening to be 0.
-  unsigned long getauxval(unsigned long type, bool* found_match = NULL) {
+  // so it's safe to call this really early on.
+  unsigned long getauxval(unsigned long type) {
     for (ElfW(auxv_t)* v = auxv; v->a_type != AT_NULL; ++v) {
       if (v->a_type == type) {
-        if (found_match != NULL) {
-            *found_match = true;
-        }
         return v->a_un.a_val;
       }
     }
-    if (found_match != NULL) {
-      *found_match = false;
-    }
     return 0;
   }