Merge "Revert "Add randomized padding around shared library mappings.""
diff --git a/libc/Android.bp b/libc/Android.bp
index f4643a9..48c9dd0 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -2478,75 +2478,6 @@
     },
 }
 
-// This is a temporary library that will use scudo as the native memory
-// allocator. To use it, add it as the first shared library.
-cc_defaults {
-    name: "libc_scudo_wrapper_defaults",
-    srcs: [
-        "bionic/gwp_asan_wrappers.cpp",
-        "bionic/heap_tagging.cpp",
-        "bionic/malloc_common.cpp",
-        "bionic/malloc_common_dynamic.cpp",
-        "bionic/malloc_heapprofd.cpp",
-        "bionic/malloc_limit.cpp",
-        "bionic/scudo_wrapper.cpp",
-        "bionic/__set_errno.cpp",
-    ],
-    cflags: [
-        "-DUSE_SCUDO",
-        "-fno-emulated-tls", // Required for GWP-ASan.
-    ],
-    shared_libs: ["libscudo_wrapper"],
-
-    header_libs: [
-        "libc_headers",
-        "gwp_asan_headers",
-    ],
-
-    static_libs: [
-        "libasync_safe",
-        "gwp_asan",
-    ],
-
-    arch: {
-        arm: {
-            srcs: [":syscalls-arm.S"],
-        },
-        arm64: {
-            srcs: [":syscalls-arm64.S"],
-        },
-        x86: {
-            srcs: [
-                "arch-x86/bionic/__libc_init_sysinfo.cpp",
-                ":syscalls-x86.S",
-            ],
-        },
-        x86_64: {
-            srcs: [":syscalls-x86_64.S"],
-        },
-    },
-
-    // Mark this library as global so it overrides all the allocation
-    // definitions properly.
-    ldflags: ["-Wl,-z,global"],
-}
-
-cc_library_shared {
-    name: "libc_scudo",
-    vendor_available: true,
-    stl: "none",
-    system_shared_libs: [],
-
-    allow_undefined_symbols: true,
-    // Like libc, disable native coverage for libc_scudo.
-    native_coverage: false,
-    apex_available: [
-        "//apex_available:platform",
-        "com.android.media.swcodec",
-    ],
-    min_sdk_version: "apex_inherit",
-}
-
 subdirs = [
     "bionic/scudo",
 ]
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index 51becf0..198bcba 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -56,8 +56,8 @@
 // +--->+-------------+------------------+
 // | +->+kInitialState+----------------+ |  malloc functions are not intercepted in any way.
 // | |  +-------+-----+                | |
-// | |          |                      | |
-// | |          v                      | |
+// | |          | HandleHeapprofd      | |
+// | |          v Signal()             | |
 // | |  +-------+----------------+     | |  currently installing the ephemeral hooks.
 // | |  |kInstallingEphemeralHook|<--+ | |
 // | |  +-------+----------------+   | | |
@@ -65,9 +65,9 @@
 // | |          v                    | | |
 // | |  +-------+---------------+    | | |  ephemeral hooks are installed. on the first call to
 // | |  |kEphemeralHookInstalled|    | | |  malloc these hooks spawn a thread that installs the
-// | |  +-------+---------------+    | | |  heapprofd hooks.
-// | |          |                    | | |
-// | |          v                    | | |
+// | |  +-------+---------------+    A B C  heapprofd hooks.
+// | |          | MallocInit         | | |
+// | |          v HeapprofdHook ()   | | |
 // | |  +-------+--------------+     | | |  first call to malloc happened. the hooks are reset to
 // | +--|kRemovingEphemeralHook|     | | |  kInitialState.
 // |    +----------------------+     | | |
@@ -81,7 +81,7 @@
 // |    +-------+------+             |   |  heapprofd hooks are installed. these forward calls to
 // |    |kHookInstalled|-------------+   |  malloc / free / etc. to heapprofd_client.so.
 // |    +-------+------+                 |
-// |            |                        |
+// |            | DispatchReset()        |
 // |            v                        |
 // |    +-------+---------+              |  currently resetting the hooks to default.
 // |----+kUninstallingHook|              |
@@ -92,6 +92,10 @@
 //      |kIncompatibleHooks+<------------+  precendence over heapprofd, so heapprofd will not get
 //      +------------------+                enabled. this is a terminal state.
 //
+//
+// A) HandleHeapprofdSignal()
+// B) HeapprofdInstallHooksAtInit() / InitHeapprofd()
+// C) HeapprofdRememberHookConflict()
 enum MallocHeapprofdState : uint8_t {
   kInitialState,
   kInstallingEphemeralHook,
diff --git a/libc/bionic/scudo/Android.bp b/libc/bionic/scudo/Android.bp
deleted file mode 100644
index 9b77c06..0000000
--- a/libc/bionic/scudo/Android.bp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-cc_library_shared {
-    name: "libscudo_wrapper",
-    vendor_available: true,
-    srcs: ["scudo.cpp"],
-
-    stl: "none",
-    system_shared_libs: [],
-    host_supported: false,
-
-    header_libs: ["libc_headers"],
-    include_dirs: [
-        "bionic/libc",
-        "bionic/libc/bionic",
-    ],
-
-    whole_static_libs: ["libasync_safe"],
-
-    arch: {
-        arm: {
-            whole_static_libs: ["libclang_rt.scudo_minimal-arm-android.static"],
-        },
-        arm64: {
-            whole_static_libs: ["libclang_rt.scudo_minimal-aarch64-android.static"],
-        },
-        x86: {
-            whole_static_libs: ["libclang_rt.scudo_minimal-i686-android.static"],
-        },
-        x86_64: {
-            whole_static_libs: ["libclang_rt.scudo_minimal-x86_64-android.static"],
-        },
-    },
-
-    // Will be referencing other libc code that won't be defined here.
-    allow_undefined_symbols: true,
-
-    multilib: {
-        lib32: {
-            version_script: "exported32.map",
-        },
-        lib64: {
-            version_script: "exported64.map",
-        },
-    },
-
-    // Like libc, disable native coverage for libscudo_wrapper.
-    native_coverage: false,
-}
diff --git a/libc/bionic/scudo/exported32.map b/libc/bionic/scudo/exported32.map
deleted file mode 100644
index 4b6791d..0000000
--- a/libc/bionic/scudo/exported32.map
+++ /dev/null
@@ -1,16 +0,0 @@
-LIBC_SCUDO {
-  global:
-    scudo_aligned_alloc;
-    scudo_calloc;
-    scudo_free;
-    scudo_mallinfo;
-    scudo_malloc;
-    scudo_malloc_usable_size;
-    scudo_memalign;
-    scudo_posix_memalign;
-    scudo_pvalloc;
-    scudo_realloc;
-    scudo_valloc;
-  local:
-    *;
-};
diff --git a/libc/bionic/scudo/exported64.map b/libc/bionic/scudo/exported64.map
deleted file mode 100644
index 1346b4b..0000000
--- a/libc/bionic/scudo/exported64.map
+++ /dev/null
@@ -1,14 +0,0 @@
-LIBC_SCUDO {
-  global:
-    scudo_aligned_alloc;
-    scudo_calloc;
-    scudo_free;
-    scudo_mallinfo;
-    scudo_malloc;
-    scudo_malloc_usable_size;
-    scudo_memalign;
-    scudo_posix_memalign;
-    scudo_realloc;
-  local:
-    *;
-};
diff --git a/libc/bionic/scudo/scudo.cpp b/libc/bionic/scudo/scudo.cpp
deleted file mode 100644
index 2cd36b1..0000000
--- a/libc/bionic/scudo/scudo.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <malloc.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <sys/param.h>
-#include <sys/prctl.h>
-
-#include "platform/bionic/macros.h"
-
-#include "scudo.h"
-
-// Disable Scudo's mismatch allocation check, as it is being triggered
-// by some third party code.
-extern "C" const char *__scudo_default_options() {
-  return "DeallocationTypeMismatch=false";
-}
-
-static inline bool AllocTooBig(size_t bytes) {
-#if defined(__LP64__)
-  if (__predict_false(bytes > 0x10000000000ULL)) {
-#else
-  if (__predict_false(bytes > 0x80000000ULL)) {
-#endif
-    return true;
-  }
-  return false;
-}
-
-void* scudo_aligned_alloc(size_t alignment, size_t size) {
-  if (alignment == 0 || !powerof2(alignment) || (size % alignment) != 0) {
-    errno = EINVAL;
-    return nullptr;
-  }
-  if (AllocTooBig(size)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-
-  return aligned_alloc(alignment, size);
-}
-
-void* scudo_calloc(size_t item_count, size_t item_size) {
-  size_t total;
-  if (__builtin_mul_overflow(item_count, item_size, &total) || AllocTooBig(total)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  return calloc(item_count, item_size);
-}
-
-void scudo_free(void* ptr) {
-  free(ptr);
-}
-
-extern "C" size_t __sanitizer_get_current_allocated_bytes();
-extern "C" size_t __sanitizer_get_heap_size();
-
-struct mallinfo scudo_mallinfo() {
-  struct mallinfo info {};
-  info.uordblks = __sanitizer_get_current_allocated_bytes();
-  info.hblkhd = __sanitizer_get_heap_size();
-  info.usmblks = info.hblkhd;
-  return info;
-}
-
-void* scudo_malloc(size_t byte_count) {
-  if (AllocTooBig(byte_count)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  return malloc(byte_count);
-}
-
-size_t scudo_malloc_usable_size(const void* ptr) {
-  return malloc_usable_size(ptr);
-}
-
-void* scudo_memalign(size_t alignment, size_t byte_count) {
-  if (AllocTooBig(byte_count)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  if (alignment != 0) {
-    if (!powerof2(alignment)) {
-      alignment = BIONIC_ROUND_UP_POWER_OF_2(alignment);
-    }
-  } else {
-    alignment = 1;
-  }
-  return memalign(alignment, byte_count);
-}
-
-void* scudo_realloc(void* ptr, size_t byte_count) {
-  if (AllocTooBig(byte_count)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  return realloc(ptr, byte_count);
-}
-
-int scudo_posix_memalign(void** memptr, size_t alignment, size_t size) {
-  if (alignment < sizeof(void*) || !powerof2(alignment)) {
-    return EINVAL;
-  }
-  if (AllocTooBig(size)) {
-    return ENOMEM;
-  }
-  return posix_memalign(memptr, alignment, size);
-}
-
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
-extern "C" void* pvalloc(size_t);
-
-void* scudo_pvalloc(size_t size) {
-  if (AllocTooBig(size)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  return pvalloc(size);
-}
-
-extern "C" void* valloc(size_t);
-
-void* scudo_valloc(size_t size) {
-  if (AllocTooBig(size)) {
-    errno = ENOMEM;
-    return nullptr;
-  }
-  return valloc(size);
-}
-#endif
-
-// Do not try and name the scudo maps by overriding __sanitizer::internal_mmap.
-// There is already a function called MmapNamed that names the maps.
-// Unfortunately, there is no easy way to override MmapNamed because
-// too much of the code is not compiled into functions available in the
-// library, and the code is complicated.
diff --git a/libc/bionic/scudo_wrapper.cpp b/libc/bionic/scudo_wrapper.cpp
deleted file mode 100644
index 1624327..0000000
--- a/libc/bionic/scudo_wrapper.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <stdio.h>
-
-#include "scudo.h"
-#include "private/bionic_globals.h"
-#include "private/WriteProtected.h"
-
-__LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
-
-// Call the libc malloc initialisers.
-__attribute__((constructor(1))) static void __scudo_preinit() {
-  __libc_globals.mutate(__libc_init_malloc);
-}
-
-extern "C" libc_shared_globals* __loader_shared_globals();
-
-__LIBC_HIDDEN__ libc_shared_globals* __libc_shared_globals() {
-  return __loader_shared_globals();
-}
-
-#if defined(__i386__)
-__LIBC_HIDDEN__ void* __libc_sysinfo = reinterpret_cast<void*>(__libc_int0x80);
-#endif
-
-extern "C" void scudo_malloc_disable_memory_tagging() {}
-
-int scudo_mallopt(int /*param*/, int /*value*/) {
-  return 0;
-}
-
-int scudo_malloc_info(int /*options*/, FILE* /*fp*/) {
-  errno = ENOTSUP;
-  return -1;
-}
-
-int scudo_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*) {
-  return 0;
-}
-
-void scudo_malloc_disable() {
-}
-
-void scudo_malloc_enable() {
-}
diff --git a/libc/include/strings.h b/libc/include/strings.h
index ba69c8d..ff6b925 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -53,6 +53,10 @@
 #define __BIONIC_STRINGS_INLINE static __inline
 #endif
 
+#undef ffs
+#undef ffsl
+#undef ffsll
+
 __BEGIN_DECLS
 
 /** Deprecated. Use memmove() instead. */
diff --git a/libc/tzcode/bionic.cpp b/libc/tzcode/bionic.cpp
index 6d84303..182fa89 100644
--- a/libc/tzcode/bionic.cpp
+++ b/libc/tzcode/bionic.cpp
@@ -105,12 +105,18 @@
   int32_t unused; // Was raw GMT offset; always 0 since tzdata2014f (L).
 };
 
+// Returns -2 for a soft failure (where the caller should try another file),
+// -1 for a hard failure (where the caller should give up), and >= 0 is a
+// file descriptor whose offset points to the data for the given olson id in
+// the given file (and *entry_length is the size of the data).
 static int __bionic_open_tzdata_path(const char* path,
                                      const char* olson_id,
                                      int32_t* entry_length) {
   int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC));
   if (fd == -1) {
-    return -2; // Distinguish failure to find any data from failure to find a specific id.
+    // We don't log here, because this is quite common --- current devices
+    // aren't expected to have the old APK tzdata, for example.
+    return -2;
   }
 
   bionic_tzdata_header_t header = {};
@@ -119,49 +125,49 @@
     fprintf(stderr, "%s: could not read header of \"%s\": %s\n",
             __FUNCTION__, path, (bytes_read == -1) ? strerror(errno) : "short read");
     close(fd);
-    return -1;
+    return -2;
   }
 
   if (strncmp(header.tzdata_version, "tzdata", 6) != 0 || header.tzdata_version[11] != 0) {
     fprintf(stderr, "%s: bad magic in \"%s\": \"%.6s\"\n", __FUNCTION__, path, header.tzdata_version);
     close(fd);
-    return -1;
+    return -2;
   }
 
   if (TEMP_FAILURE_RETRY(lseek(fd, ntohl(header.index_offset), SEEK_SET)) == -1) {
     fprintf(stderr, "%s: couldn't seek to index in \"%s\": %s\n", __FUNCTION__, path, strerror(errno));
     close(fd);
-    return -1;
+    return -2;
   }
 
   if (ntohl(header.index_offset) > ntohl(header.data_offset)) {
     fprintf(stderr, "%s: invalid data and index offsets in \"%s\": %u %u\n",
             __FUNCTION__, path, ntohl(header.data_offset), ntohl(header.index_offset));
     close(fd);
-    return -1;
+    return -2;
   }
   const size_t index_size = ntohl(header.data_offset) - ntohl(header.index_offset);
   if ((index_size % sizeof(index_entry_t)) != 0) {
     fprintf(stderr, "%s: invalid index size in \"%s\": %zd\n", __FUNCTION__, path, index_size);
     close(fd);
-    return -1;
+    return -2;
   }
 
-  off_t specific_zone_offset = -1;
   char* index = reinterpret_cast<char*>(malloc(index_size));
   if (index == nullptr) {
     fprintf(stderr, "%s: couldn't allocate %zd-byte index for \"%s\"\n", __FUNCTION__, index_size, path);
     close(fd);
-    return -1;
+    return -2;
   }
   if (TEMP_FAILURE_RETRY(read(fd, index, index_size)) != static_cast<ssize_t>(index_size)) {
     fprintf(stderr, "%s: could not read index of \"%s\": %s\n",
             __FUNCTION__, path, (bytes_read == -1) ? strerror(errno) : "short read");
     free(index);
     close(fd);
-    return -1;
+    return -2;
   }
 
+  off_t specific_zone_offset = -1;
   size_t id_count = index_size / sizeof(index_entry_t);
   index_entry_t* entry = reinterpret_cast<index_entry_t*>(index);
   for (size_t i = 0; i < id_count; ++i) {
@@ -180,6 +186,9 @@
   free(index);
 
   if (specific_zone_offset == -1) {
+    // We found a valid tzdata file, but didn't find the requested id in it.
+    // Give up now, and don't try fallback tzdata files. We don't log here
+    // because for all we know the given olson id was nonsense.
     close(fd);
     return -1;
   }
@@ -188,11 +197,9 @@
     fprintf(stderr, "%s: could not seek to %ld in \"%s\": %s\n",
             __FUNCTION__, specific_zone_offset, path, strerror(errno));
     close(fd);
-    return -1;
+    return -2;
   }
 
-  // TODO: check that there's TZ_MAGIC at this offset, so we can fall back to the other file if not.
-
   return fd;
 }
 
@@ -204,8 +211,9 @@
   //    tried first because it allows us to test that the time zone updates
   //    via APK mechanism still works even on devices with the time zone
   //    module.
+  //    TODO: remove this when those devices are no longer supported.
   // 2: The time zone data module which contains the main copy. This is the
-  //    common case.
+  //    common case for current devices.
   // 3: The ultimate fallback: the non-updatable copy in /system.
 
 #if defined(__ANDROID__)
@@ -214,15 +222,15 @@
 
   fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/current/tzdata",
                                  olson_id, entry_length);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 
   fd = __bionic_open_tzdata_path("/apex/com.android.tzdata/etc/tz/tzdata",
                                  olson_id, entry_length);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 
   fd = __bionic_open_tzdata_path("/system/usr/share/zoneinfo/tzdata",
                                  olson_id, entry_length);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 #else
   // On the host, we don't expect the hard-coded locations above to exist, and
   // we're not worried about security so we trust $ANDROID_DATA,
@@ -232,17 +240,17 @@
   char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata");
   fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
   free(path);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 
   path = make_path("ANDROID_TZDATA_ROOT", "/etc/tz/tzdata");
   fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
   free(path);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 
   path = make_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata");
   fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
   free(path);
-  if (fd >= 0) return fd;
+  if (fd >= -1) return fd;
 #endif
 
   // Not finding any tzdata is more serious that not finding a specific zone,
@@ -253,5 +261,6 @@
     fprintf(stderr, "%s: couldn't find any tzdata when looking for %s!\n", __FUNCTION__, olson_id);
   }
 
+  // Otherwise we were successful.
   return fd;
 }
diff --git a/linker/linker.cpp b/linker/linker.cpp
index edf0329..10608f4 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3372,6 +3372,22 @@
   return ld_config_file_vndk;
 }
 
+bool is_linker_config_expected(const char* executable_path) {
+  // Do not raise message from a host environment which is expected to miss generated linker
+  // configuration.
+#if !defined(__ANDROID__)
+  return false;
+#endif
+
+  if (strcmp(executable_path, "/system/bin/init") == 0) {
+    // Generated linker configuration can be missed from processes executed
+    // with init binary
+    return false;
+  }
+
+  return true;
+}
+
 static std::string get_ld_config_file_path(const char* executable_path) {
 #ifdef USE_LD_CONFIG_FILE
   // This is a debugging/testing only feature. Must not be available on
@@ -3400,12 +3416,10 @@
     return kLdGeneratedConfigFilePath;
   }
 
-  // Do not raise message from a host environment which is expected to miss generated linker
-  // configuration.
-#if defined(__ANDROID__)
-  DL_WARN("Warning: failed to find generated linker configuration from \"%s\"",
-          kLdGeneratedConfigFilePath);
-#endif
+  if (is_linker_config_expected(executable_path)) {
+    DL_WARN("Warning: failed to find generated linker configuration from \"%s\"",
+            kLdGeneratedConfigFilePath);
+  }
 
   path = get_ld_config_file_vndk_path();
   if (file_exists(path.c_str())) {
diff --git a/tests/mte_test.cpp b/tests/mte_test.cpp
index ff8cde6..f329d8d 100644
--- a/tests/mte_test.cpp
+++ b/tests/mte_test.cpp
@@ -22,6 +22,7 @@
 
 #include <android-base/macros.h>
 #include <bionic/mte.h>
+#include "utils.h"
 
 __attribute__((no_sanitize("hwaddress")))
 static void test_tag_mismatch() {
@@ -48,6 +49,11 @@
 }
 
 TEST(mte_test, ScopedDisableMTE) {
+  // With native_bridge, native and emulated parts exchange data, including pointers.
+  // This implies tagging on native and emulated architectures should match, which is
+  // not the case at the moment.
+  SKIP_WITH_NATIVE_BRIDGE;
+
   test_tag_mismatch();
 }