Merge "Add TEST_MAPPING."
diff --git a/build/bionic.go b/build/bionic.go
index 93c2494..54ad10b 100644
--- a/build/bionic.go
+++ b/build/bionic.go
@@ -89,6 +89,9 @@
// Symlinks to the mountpoints from the system and recovery partitions
// Symlinks names will have the same suffix as the mount point
Symlinks []string
+
+ // List of sanitizer names that this APEX is enabled for
+ SanitizerNames []string `blueprint:"mutated"`
}
type dependencyTag struct {
@@ -98,6 +101,31 @@
var mountsourceTag = dependencyTag{name: "mountsource"}
+
+func (m *bionicMountpoint) EnableSanitizer(sanitizerName string) {
+ if !android.InList(sanitizerName, m.properties.SanitizerNames) {
+ m.properties.SanitizerNames = append(m.properties.SanitizerNames, sanitizerName)
+ }
+}
+
+func (m *bionicMountpoint) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
+ if android.InList(sanitizerName, m.properties.SanitizerNames) {
+ return true
+ }
+
+ // Then follow the global setting
+ globalSanitizerNames := []string{}
+ if m.Host() {
+ globalSanitizerNames = ctx.Config().SanitizeHost()
+ } else {
+ arches := ctx.Config().SanitizeDeviceArch()
+ if len(arches) == 0 || android.InList(m.Arch().ArchType.Name, arches) {
+ globalSanitizerNames = ctx.Config().SanitizeDevice()
+ }
+ }
+ return android.InList(sanitizerName, globalSanitizerNames)
+}
+
func (m *bionicMountpoint) DepsMutator(ctx android.BottomUpMutatorContext) {
if Bool(m.properties.Library) == Bool(m.properties.Binary) {
ctx.ModuleErrorf("either binary or library must be set to true")
diff --git a/libc/Android.bp b/libc/Android.bp
index 1487975..262d951 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -77,9 +77,14 @@
native_coverage: false,
recovery_available: true,
- // TODO(ivanlozano): Remove after b/118321713
- no_libcrt: true,
- xom: false,
+ arch: {
+ x86: {
+ no_libcrt: true,
+ },
+ x86_64: {
+ no_libcrt: true,
+ },
+ },
}
// ========================================================
@@ -765,7 +770,7 @@
"arch-arm/bionic/atomics_arm.c",
"arch-arm/bionic/__bionic_clone.S",
"arch-arm/bionic/_exit_with_stack_teardown.S",
- "arch-arm/bionic/libgcc_compat.c",
+ "arch-arm/bionic/libcrt_compat.c",
"arch-arm/bionic/popcount_tab.c",
"arch-arm/bionic/__restore.S",
"arch-arm/bionic/setjmp.S",
@@ -849,7 +854,7 @@
"arch-mips/bionic/__bionic_clone.S",
"arch-mips/bionic/cacheflush.cpp",
"arch-mips/bionic/_exit_with_stack_teardown.S",
- "arch-mips/bionic/libgcc_compat.c",
+ "arch-mips/bionic/libcrt_compat.c",
"arch-mips/bionic/setjmp.S",
"arch-mips/bionic/syscall.S",
"arch-mips/bionic/vfork.S",
@@ -919,7 +924,7 @@
"arch-x86/bionic/__bionic_clone.S",
"arch-x86/bionic/_exit_with_stack_teardown.S",
- "arch-x86/bionic/libgcc_compat.c",
+ "arch-x86/bionic/libcrt_compat.c",
"arch-x86/bionic/__restore.S",
"arch-x86/bionic/setjmp.S",
"arch-x86/bionic/syscall.S",
diff --git a/libc/arch-arm/bionic/libgcc_compat.c b/libc/arch-arm/bionic/libcrt_compat.c
similarity index 95%
rename from libc/arch-arm/bionic/libgcc_compat.c
rename to libc/arch-arm/bionic/libcrt_compat.c
index abd1422..22a3387 100644
--- a/libc/arch-arm/bionic/libgcc_compat.c
+++ b/libc/arch-arm/bionic/libcrt_compat.c
@@ -90,6 +90,8 @@
extern char __floatunsisf;
extern char __gedf2;
extern char __gtdf2;
+extern char __gnu_ldivmod_helper;
+extern char __gnu_uldivmod_helper;
extern char __ledf2;
extern char __ltdf2;
extern char __muldf3;
@@ -101,10 +103,11 @@
extern char __subdf3;
extern char __subsf3;
extern char __truncdfsf2;
+extern char __udivdi3;
extern char __unorddf2;
extern char __unordsf2;
-void* __bionic_libgcc_compat_symbols[] = {
+void* __bionic_libcrt_compat_symbols[] = {
&__adddf3,
&__addsf3,
&__aeabi_cdcmpeq,
@@ -169,6 +172,8 @@
&__floatunsisf,
&__gedf2,
&__gtdf2,
+ &__gnu_ldivmod_helper,
+ &__gnu_uldivmod_helper,
&__ledf2,
&__ltdf2,
&__muldf3,
@@ -180,6 +185,7 @@
&__subdf3,
&__subsf3,
&__truncdfsf2,
+ &__udivdi3,
&__unorddf2,
&__unordsf2,
};
diff --git a/libc/arch-mips/bionic/libgcc_compat.c b/libc/arch-mips/bionic/libcrt_compat.c
similarity index 97%
rename from libc/arch-mips/bionic/libgcc_compat.c
rename to libc/arch-mips/bionic/libcrt_compat.c
index 1a0f566..cfa41f2 100644
--- a/libc/arch-mips/bionic/libgcc_compat.c
+++ b/libc/arch-mips/bionic/libcrt_compat.c
@@ -32,7 +32,7 @@
extern char __udivdi3;
extern char __umoddi3;
-void* __bionic_libgcc_compat_symbols[] = {
+void* __bionic_libcrt_compat_symbols[] = {
&__divdi3,
&__moddi3,
&__popcountsi2,
diff --git a/libc/arch-x86/bionic/libgcc_compat.c b/libc/arch-x86/bionic/libcrt_compat.c
similarity index 97%
rename from libc/arch-x86/bionic/libgcc_compat.c
rename to libc/arch-x86/bionic/libcrt_compat.c
index 1a0f566..cfa41f2 100644
--- a/libc/arch-x86/bionic/libgcc_compat.c
+++ b/libc/arch-x86/bionic/libcrt_compat.c
@@ -32,7 +32,7 @@
extern char __udivdi3;
extern char __umoddi3;
-void* __bionic_libgcc_compat_symbols[] = {
+void* __bionic_libcrt_compat_symbols[] = {
&__divdi3,
&__moddi3,
&__popcountsi2,
diff --git a/libc/async_safe/Android.bp b/libc/async_safe/Android.bp
index a54d3b0..6ae1c42 100644
--- a/libc/async_safe/Android.bp
+++ b/libc/async_safe/Android.bp
@@ -12,7 +12,19 @@
recovery_available: true,
include_dirs: ["bionic/libc"],
- header_libs: ["libc_headers"],
+ header_libs: ["libc_headers", "liblog_headers"],
export_include_dirs: ["include"],
+ export_header_lib_headers: ["liblog_headers"],
+ stl: "none",
+}
+
+cc_library_headers {
+ name: "libasync_safe_headers",
+ recovery_available: true,
+
+ export_include_dirs: ["include"],
+
+ system_shared_libs: [],
+ stl: "none",
}
diff --git a/libc/arch-mips/bionic/libgcc_compat.c b/libc/async_safe/include/async_safe/CHECK.h
similarity index 74%
copy from libc/arch-mips/bionic/libgcc_compat.c
copy to libc/async_safe/include/async_safe/CHECK.h
index 1a0f566..bec89a3 100644
--- a/libc/arch-mips/bionic/libgcc_compat.c
+++ b/libc/async_safe/include/async_safe/CHECK.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,16 +26,22 @@
* SUCH DAMAGE.
*/
-extern char __divdi3;
-extern char __moddi3;
-extern char __popcountsi2;
-extern char __udivdi3;
-extern char __umoddi3;
+#pragma once
-void* __bionic_libgcc_compat_symbols[] = {
- &__divdi3,
- &__moddi3,
- &__popcountsi2,
- &__udivdi3,
- &__umoddi3,
-};
+#include <sys/cdefs.h>
+
+#include <async_safe/log.h>
+
+__BEGIN_DECLS
+
+// TODO: replace this with something more like <android-base/logging.h>'s family of macros.
+
+#define CHECK(predicate) \
+ do { \
+ if (!(predicate)) { \
+ async_safe_fatal("%s:%d: %s CHECK '" #predicate "' failed", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ } \
+ } while(0)
+
+__END_DECLS
diff --git a/libc/async_safe/include/async_safe/log.h b/libc/async_safe/include/async_safe/log.h
index df68062..0e02ea7 100644
--- a/libc/async_safe/include/async_safe/log.h
+++ b/libc/async_safe/include/async_safe/log.h
@@ -34,36 +34,14 @@
#include <stdint.h>
#include <stdlib.h>
+// This file is an alternative to <android/log.h>, but reuses
+// `android_LogPriority` and should not have conflicting identifiers.
+#include <android/log.h>
+
// These functions do not allocate memory to send data to the log.
__BEGIN_DECLS
-enum {
- ANDROID_LOG_UNKNOWN = 0,
- ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
-
- ANDROID_LOG_VERBOSE,
- ANDROID_LOG_DEBUG,
- ANDROID_LOG_INFO,
- ANDROID_LOG_WARN,
- ANDROID_LOG_ERROR,
- ANDROID_LOG_FATAL,
-
- ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
-};
-
-enum {
- LOG_ID_MIN = 0,
-
- LOG_ID_MAIN = 0,
- LOG_ID_RADIO = 1,
- LOG_ID_EVENTS = 2,
- LOG_ID_SYSTEM = 3,
- LOG_ID_CRASH = 4,
-
- LOG_ID_MAX
-};
-
// Formats a message to the log (priority 'fatal'), then aborts.
// Implemented as a macro so that async_safe_fatal isn't on the stack when we crash:
// we appear to go straight from the caller to abort, saving an uninteresting stack
@@ -91,16 +69,8 @@
int async_safe_format_fd(int fd, const char* format , ...) __printflike(2, 3);
int async_safe_format_fd_va_list(int fd, const char* format, va_list args);
-int async_safe_format_log(int pri, const char* tag, const char* fmt, ...) __printflike(3, 4);
-int async_safe_format_log_va_list(int pri, const char* tag, const char* fmt, va_list ap);
-int async_safe_write_log(int pri, const char* tag, const char* msg);
-
-#define CHECK(predicate) \
- do { \
- if (!(predicate)) { \
- async_safe_fatal("%s:%d: %s CHECK '" #predicate "' failed", \
- __FILE__, __LINE__, __FUNCTION__); \
- } \
- } while(0)
+int async_safe_format_log(int priority, const char* tag, const char* fmt, ...) __printflike(3, 4);
+int async_safe_format_log_va_list(int priority, const char* tag, const char* fmt, va_list ap);
+int async_safe_write_log(int priority, const char* tag, const char* msg);
__END_DECLS
diff --git a/libc/bionic/bionic_allocator.cpp b/libc/bionic/bionic_allocator.cpp
index d9302ad..da0f7d0 100644
--- a/libc/bionic/bionic_allocator.cpp
+++ b/libc/bionic/bionic_allocator.cpp
@@ -38,6 +38,7 @@
#include <new>
#include <async_safe/log.h>
+#include <async_safe/CHECK.h>
#include "private/bionic_macros.h"
#include "private/bionic_page.h"
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 1c3f53f..ce3e761 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -303,23 +303,25 @@
return true;
}
-static void InstallHooks(libc_globals* globals, const char* options, const char* prefix,
+static bool InstallHooks(libc_globals* globals, const char* options, const char* prefix,
const char* shared_lib) {
void* impl_handle = LoadSharedLibrary(shared_lib, prefix, &globals->malloc_dispatch_table);
if (impl_handle == nullptr) {
- return;
+ return false;
}
init_func_t init_func = reinterpret_cast<init_func_t>(gFunctions[FUNC_INITIALIZE]);
if (!init_func(&__libc_malloc_default_dispatch, &gMallocLeakZygoteChild, options)) {
error_log("%s: failed to enable malloc %s", getprogname(), prefix);
ClearGlobalFunctions();
- return;
+ return false;
}
if (!FinishInstallHooks(globals, options, prefix)) {
dlclose(impl_handle);
+ return false;
}
+ return true;
}
// Initializes memory allocation framework once per process.
@@ -329,16 +331,25 @@
// Prefer malloc debug since it existed first and is a more complete
// malloc interceptor than the hooks.
+ bool hook_installed = false;
if (CheckLoadMallocDebug(&options)) {
- InstallHooks(globals, options, kDebugPrefix, kDebugSharedLib);
+ hook_installed = InstallHooks(globals, options, kDebugPrefix, kDebugSharedLib);
} else if (CheckLoadMallocHooks(&options)) {
- InstallHooks(globals, options, kHooksPrefix, kHooksSharedLib);
- } else if (HeapprofdShouldLoad()) {
- HeapprofdInstallHooksAtInit(globals);
+ hook_installed = InstallHooks(globals, options, kHooksPrefix, kHooksSharedLib);
}
- // Install this last to avoid as many race conditions as possible.
- HeapprofdInstallSignalHandler();
+ if (!hook_installed) {
+ if (HeapprofdShouldLoad()) {
+ HeapprofdInstallHooksAtInit(globals);
+ }
+
+ // Install this last to avoid as many race conditions as possible.
+ HeapprofdInstallSignalHandler();
+ } else {
+ // Install a signal handler that prints an error since we don't support
+ // heapprofd and any other hook to be installed at the same time.
+ HeapprofdInstallErrorSignalHandler();
+ }
}
// Initializes memory allocation framework.
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index fb7266a..c492bac 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -211,6 +211,16 @@
sigaction(kHeapprofdSignal, &action, nullptr);
}
+static void DisplayError(int) {
+ error_log("Cannot install heapprofd while malloc debug/malloc hooks are enabled.");
+}
+
+void HeapprofdInstallErrorSignalHandler() {
+ struct sigaction action = {};
+ action.sa_handler = DisplayError;
+ sigaction(kHeapprofdSignal, &action, nullptr);
+}
+
static void CommonInstallHooks(libc_globals* globals) {
void* impl_handle = atomic_load(&gHeapprofdHandle);
bool reusing_handle = impl_handle != nullptr;
diff --git a/libc/bionic/malloc_heapprofd.h b/libc/bionic/malloc_heapprofd.h
index 91188b9..5a766fc 100644
--- a/libc/bionic/malloc_heapprofd.h
+++ b/libc/bionic/malloc_heapprofd.h
@@ -38,4 +38,6 @@
void HeapprofdInstallSignalHandler();
+void HeapprofdInstallErrorSignalHandler();
+
bool HeapprofdMallopt(int optcode, void* arg, size_t arg_size);
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp
index bc3ba76..c508db1 100644
--- a/libc/bionic/system_property_set.cpp
+++ b/libc/bionic/system_property_set.cpp
@@ -42,6 +42,7 @@
#include <unistd.h>
#include <async_safe/log.h>
+#include <async_safe/CHECK.h>
#include "private/bionic_defs.h"
#include "private/bionic_macros.h"
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 6a6ea7d..62aea27 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1561,7 +1561,7 @@
__ashldi3; # arm
__ashrdi3; # arm
__bionic_brk; # arm x86 mips
- __bionic_libgcc_compat_symbols; # arm x86
+ __bionic_libcrt_compat_symbols; # arm x86
__cmpdf2; # arm
__divdf3; # arm
__divdi3; # arm x86 mips
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp
index 638061b..6e9d24f 100644
--- a/libc/malloc_debug/PointerData.cpp
+++ b/libc/malloc_debug/PointerData.cpp
@@ -266,12 +266,12 @@
error_log(" hash_index %zu does not have matching frame data.", hash_index);
}
-void PointerData::LogFreeError(const FreePointerInfoType& info, size_t usable_size) {
+void PointerData::LogFreeError(const FreePointerInfoType& info, size_t max_cmp_bytes) {
error_log(LOG_DIVIDER);
uint8_t* memory = reinterpret_cast<uint8_t*>(info.pointer);
error_log("+++ ALLOCATION %p USED AFTER FREE", memory);
uint8_t fill_free_value = g_debug->config().fill_free_value();
- for (size_t i = 0; i < usable_size; i++) {
+ for (size_t i = 0; i < max_cmp_bytes; i++) {
if (memory[i] != fill_free_value) {
error_log(" allocation[%zu] = 0x%02x (expected 0x%02x)", i, memory[i], fill_free_value);
}
@@ -314,11 +314,12 @@
size_t bytes = (usable_size < g_debug->config().fill_on_free_bytes())
? usable_size
: g_debug->config().fill_on_free_bytes();
+ size_t max_cmp_bytes = bytes;
const uint8_t* memory = reinterpret_cast<const uint8_t*>(info.pointer);
while (bytes > 0) {
size_t bytes_to_cmp = (bytes < g_cmp_mem.size()) ? bytes : g_cmp_mem.size();
if (memcmp(memory, g_cmp_mem.data(), bytes_to_cmp) != 0) {
- LogFreeError(info, usable_size);
+ LogFreeError(info, max_cmp_bytes);
}
bytes -= bytes_to_cmp;
memory = &memory[bytes_to_cmp];
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 44f9795..6da95ca 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -990,6 +990,35 @@
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugTest, free_track_pointer_modified_after_free) {
+ Init("free_track=4 fill_on_free=2 free_track_backtrace_num_frames=0");
+
+ void* pointers[5];
+ for (size_t i = 0; i < sizeof(pointers) / sizeof(void*); i++) {
+ pointers[i] = debug_malloc(100);
+ ASSERT_TRUE(pointers[i] != nullptr);
+ memset(pointers[i], 0, 100);
+ }
+
+ debug_free(pointers[0]);
+
+ // overwrite the whole pointer, only expect errors on the fill bytes we check.
+ memset(pointers[0], 0x20, 100);
+
+ for (size_t i = 1; i < sizeof(pointers) / sizeof(void*); i++) {
+ debug_free(pointers[i]);
+ }
+
+ std::string expected_log(DIVIDER);
+ expected_log += android::base::StringPrintf("6 malloc_debug +++ ALLOCATION %p USED AFTER FREE\n",
+ pointers[0]);
+ expected_log += "6 malloc_debug allocation[0] = 0x20 (expected 0xef)\n";
+ expected_log += "6 malloc_debug allocation[1] = 0x20 (expected 0xef)\n";
+ expected_log += DIVIDER;
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugTest, get_malloc_leak_info_invalid) {
Init("fill");
diff --git a/libc/symbol_ordering b/libc/symbol_ordering
index c39fac5..6fcc09e 100644
--- a/libc/symbol_ordering
+++ b/libc/symbol_ordering
@@ -3,8 +3,6 @@
# symbols by size, we usually have less dirty pages at runtime, because small
# symbols are grouped together.
-je_background_thread_enabled_state
-je_can_enable_background_thread
_ZZ17__find_icu_symbolPKcE9found_icu
_ZL24gHeapprofdInitInProgress
_ZL27gHeapprofdInitHookInstalled
@@ -19,7 +17,6 @@
had_conf_error
malloc_slow_flags
je_opt_background_thread
-background_thread_enabled_at_fork
ctl_initialized
je_log_init_done
mmap_flags
@@ -70,8 +67,6 @@
seed48.sseed
ether_aton.addr
je_background_thread_info
-je_max_background_threads
-je_n_background_threads
je_malloc_message
je_tcache_bin_info
je_tcache_maxclass
@@ -92,7 +87,6 @@
je_opt_muzzy_decay_ms
dirty_decay_ms_default.0
muzzy_decay_ms_default.0
-pthread_create_fptr
b0
ctl_arenas
ctl_stats
diff --git a/libc/system_properties/Android.bp b/libc/system_properties/Android.bp
index f94cda9..911afb1 100644
--- a/libc/system_properties/Android.bp
+++ b/libc/system_properties/Android.bp
@@ -12,8 +12,8 @@
whole_static_libs: [
"libpropertyinfoparser",
],
- static_libs: [
- "libasync_safe",
+ header_libs: [
+ "libasync_safe_headers",
],
include_dirs: [
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 43ddbfe..642cc7a 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -92,6 +92,8 @@
nocrt: true,
system_shared_libs: [],
+
+ // Opt out of native_coverage when opting out of system_shared_libs
native_coverage: false,
// This is placeholder library the actual implementation is (currently)
diff --git a/linker/Android.bp b/linker/Android.bp
index fed921d..613be3d 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -296,6 +296,10 @@
},
},
system_shared_libs: [],
+
+ // Opt out of native_coverage when opting out of system_shared_libs
+ native_coverage: false,
+
target: {
android: {
static_libs: ["libdebuggerd_handler_fallback"],
@@ -364,7 +368,46 @@
nocrt: true,
system_shared_libs: [],
+ // Opt out of native_coverage when opting out of system_shared_libs
+ native_coverage: false,
+
sanitize: {
never: true,
},
}
+
+cc_test {
+ name: "linker-unit-tests",
+
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Wextra",
+ "-Wunused",
+ "-Werror",
+ ],
+
+ // We need to access Bionic private headers in the linker.
+ include_dirs: ["bionic/libc"],
+
+ srcs: [
+ // Tests.
+ "linker_block_allocator_test.cpp",
+ "linker_config_test.cpp",
+ "linked_list_test.cpp",
+ "linker_sleb128_test.cpp",
+ "linker_utils_test.cpp",
+
+ // Parts of the linker that we're testing.
+ "linker_block_allocator.cpp",
+ "linker_config.cpp",
+ "linker_test_globals.cpp",
+ "linker_utils.cpp",
+ ],
+
+ static_libs: [
+ "libasync_safe",
+ "libbase",
+ "liblog",
+ ],
+}
diff --git a/linker/Android.mk b/linker/Android.mk
deleted file mode 100644
index ea7451c..0000000
--- a/linker/Android.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/linker/tests/linked_list_test.cpp b/linker/linked_list_test.cpp
similarity index 99%
rename from linker/tests/linked_list_test.cpp
rename to linker/linked_list_test.cpp
index 2b88ed0..71a7d09 100644
--- a/linker/tests/linked_list_test.cpp
+++ b/linker/linked_list_test.cpp
@@ -32,7 +32,7 @@
#include <gtest/gtest.h>
-#include "../linked_list.h"
+#include "linked_list.h"
namespace {
diff --git a/linker/linker.cpp b/linker/linker.cpp
index ed84a46..8a70ca9 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2171,9 +2171,13 @@
new_name);
// Some APEXs could be optionally disabled. Only translate the path
// when the old file is absent and the new file exists.
+ // TODO(b/124218500): Re-enable it once app compat issue is resolved
+ /*
if (file_exists(name)) {
LD_LOG(kLogDlopen, "dlopen %s exists, not translating", name);
- } else if (!file_exists(new_name)) {
+ } else
+ */
+ if (!file_exists(new_name)) {
LD_LOG(kLogDlopen, "dlopen %s does not exist, not translating",
new_name);
} else {
diff --git a/linker/tests/linker_block_allocator_test.cpp b/linker/linker_block_allocator_test.cpp
similarity index 98%
rename from linker/tests/linker_block_allocator_test.cpp
rename to linker/linker_block_allocator_test.cpp
index d5eb97c..359eefb 100644
--- a/linker/tests/linker_block_allocator_test.cpp
+++ b/linker/linker_block_allocator_test.cpp
@@ -32,7 +32,7 @@
#include <gtest/gtest.h>
-#include "../linker_block_allocator.h"
+#include "linker_block_allocator.h"
#include <unistd.h>
@@ -145,4 +145,3 @@
testing::FLAGS_gtest_death_test_style = "threadsafe";
ASSERT_EXIT(protect_all(), testing::KilledBySignal(SIGSEGV), "trying to access protected page");
}
-
diff --git a/linker/tests/linker_config_test.cpp b/linker/linker_config_test.cpp
similarity index 99%
rename from linker/tests/linker_config_test.cpp
rename to linker/linker_config_test.cpp
index 14fd132..6a55bb2 100644
--- a/linker/tests/linker_config_test.cpp
+++ b/linker/linker_config_test.cpp
@@ -32,8 +32,8 @@
#include <gtest/gtest.h>
-#include "../linker_config.h"
-#include "../linker_utils.h"
+#include "linker_config.h"
+#include "linker_utils.h"
#include <unistd.h>
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 862ea12..7a1cb3c 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -56,6 +56,7 @@
#include <unistd.h>
#include <async_safe/log.h>
+#include <async_safe/CHECK.h>
__LIBC_HIDDEN__ extern int g_ld_debug_verbosity;
diff --git a/linker/tests/linker_sleb128_test.cpp b/linker/linker_sleb128_test.cpp
similarity index 98%
rename from linker/tests/linker_sleb128_test.cpp
rename to linker/linker_sleb128_test.cpp
index 551faf2..9e819c6 100644
--- a/linker/tests/linker_sleb128_test.cpp
+++ b/linker/linker_sleb128_test.cpp
@@ -32,7 +32,7 @@
#include <gtest/gtest.h>
-#include "../linker_sleb128.h"
+#include "linker_sleb128.h"
TEST(linker_sleb128, smoke) {
std::vector<uint8_t> encoding;
diff --git a/linker/tests/linker_globals.cpp b/linker/linker_test_globals.cpp
similarity index 100%
rename from linker/tests/linker_globals.cpp
rename to linker/linker_test_globals.cpp
diff --git a/linker/linker_tls.cpp b/linker/linker_tls.cpp
index a3aa9bf..d2edbb3 100644
--- a/linker/linker_tls.cpp
+++ b/linker/linker_tls.cpp
@@ -30,6 +30,7 @@
#include <vector>
+#include "async_safe/CHECK.h"
#include "private/ScopedRWLock.h"
#include "private/ScopedSignalBlocker.h"
#include "private/bionic_defs.h"
diff --git a/linker/tests/linker_utils_test.cpp b/linker/linker_utils_test.cpp
similarity index 99%
rename from linker/tests/linker_utils_test.cpp
rename to linker/linker_utils_test.cpp
index e406af5..44907da 100644
--- a/linker/tests/linker_utils_test.cpp
+++ b/linker/linker_utils_test.cpp
@@ -32,7 +32,7 @@
#include <gtest/gtest.h>
-#include "../linker_utils.h"
+#include "linker_utils.h"
TEST(linker_utils, format_string) {
std::vector<std::pair<std::string, std::string>> params = {{ "LIB", "lib32"}, { "SDKVER", "42"}};
diff --git a/linker/tests/Android.mk b/linker/tests/Android.mk
deleted file mode 100644
index 63e0555..0000000
--- a/linker/tests/Android.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := linker-unit-tests
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_CFLAGS += -g -Wall -Wextra -Wunused -Werror
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../libc/
-
-LOCAL_SRC_FILES := \
- linker_block_allocator_test.cpp \
- linker_config_test.cpp \
- linker_globals.cpp \
- linked_list_test.cpp \
- linker_sleb128_test.cpp \
- linker_utils_test.cpp \
- ../linker_block_allocator.cpp \
- ../linker_config.cpp \
- ../linker_utils.cpp \
-
-LOCAL_STATIC_LIBRARIES += libasync_safe libbase liblog
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/malloc_iterate_test.cpp b/tests/malloc_iterate_test.cpp
index 5e60a6d..76583eb 100644
--- a/tests/malloc_iterate_test.cpp
+++ b/tests/malloc_iterate_test.cpp
@@ -92,14 +92,15 @@
test_data->total_allocated_bytes = 0;
// Find all of the maps that are [anon:libc_malloc].
- ASSERT_TRUE(android::procinfo::ReadMapFile("/proc/self/maps",
- [&](uint64_t start, uint64_t end, uint16_t, uint64_t, const char* name) {
- if (std::string(name) == "[anon:libc_malloc]") {
- malloc_disable();
- malloc_iterate(start, end - start, SavePointers, test_data);
- malloc_enable();
- }
- }));
+ ASSERT_TRUE(android::procinfo::ReadMapFile(
+ "/proc/self/maps",
+ [&](uint64_t start, uint64_t end, uint16_t, uint64_t, ino_t, const char* name) {
+ if (std::string(name) == "[anon:libc_malloc]") {
+ malloc_disable();
+ malloc_iterate(start, end - start, SavePointers, test_data);
+ malloc_enable();
+ }
+ }));
for (size_t i = 0; i < test_data->allocs.size(); i++) {
EXPECT_EQ(1UL, test_data->allocs[i].count) << "Failed on size " << test_data->allocs[i].size;
@@ -180,14 +181,15 @@
TestDataType test_data = {};
// Find all of the maps that are not [anon:libc_malloc].
- ASSERT_TRUE(android::procinfo::ReadMapFile("/proc/self/maps",
- [&](uint64_t start, uint64_t end, uint16_t, uint64_t, const char* name) {
- if (std::string(name) != "[anon:libc_malloc]") {
- malloc_disable();
- malloc_iterate(start, end - start, SavePointers, &test_data);
- malloc_enable();
- }
- }));
+ ASSERT_TRUE(android::procinfo::ReadMapFile(
+ "/proc/self/maps",
+ [&](uint64_t start, uint64_t end, uint16_t, uint64_t, ino_t, const char* name) {
+ if (std::string(name) != "[anon:libc_malloc]") {
+ malloc_disable();
+ malloc_iterate(start, end - start, SavePointers, &test_data);
+ malloc_enable();
+ }
+ }));
ASSERT_EQ(0UL, test_data.total_allocated_bytes);
#else
diff --git a/tools/Android.mk b/tools/Android.mk
deleted file mode 100644
index 4dd66fe..0000000
--- a/tools/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (C) 2015 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-subdir-makefiles)