Merge changes If42905f3,Id351a993,I8a082fd0
* changes:
fdtrack: don't do anything while vforked.
fdsan: don't do anything when vforked.
Track whether a thread is currently vforked.
diff --git a/libc/Android.bp b/libc/Android.bp
index d5d0afb..7614784 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -65,7 +65,13 @@
"bionic/libc/async_safe/include",
],
- header_libs: ["gwp_asan_headers"],
+ header_libs: [
+ "libc_headers",
+ "gwp_asan_headers",
+ ],
+ export_header_lib_headers: [
+ "libc_headers",
+ ],
stl: "none",
system_shared_libs: [],
@@ -88,6 +94,12 @@
experimental_mte: {
cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
},
+ malloc_zero_contents: {
+ cflags: ["-DSCUDO_ZERO_CONTENTS"],
+ },
+ malloc_pattern_fill_contents: {
+ cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
+ },
},
}
@@ -1577,7 +1589,6 @@
],
name: "libc",
static_ndk_lib: true,
- export_include_dirs: ["include"],
product_variables: {
platform_sdk_version: {
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
@@ -1751,10 +1762,12 @@
// Headers that only other parts of the platform can include.
cc_library_headers {
name: "bionic_libc_platform_headers",
+ defaults: ["linux_bionic_supported"],
visibility: [
"//art:__subpackages__",
"//bionic:__subpackages__",
"//frameworks:__subpackages__",
+ "//device/generic/goldfish-opengl:__subpackages__",
"//external/gwp_asan:__subpackages__",
"//external/perfetto:__subpackages__",
"//external/scudo:__subpackages__",
@@ -1762,7 +1775,6 @@
"//system/core/libunwindstack:__subpackages__",
"//system/memory/libmemunreachable:__subpackages__",
],
- host_supported: true,
vendor_available: true,
ramdisk_available: true,
recovery_available: true,
@@ -1773,11 +1785,22 @@
system_shared_libs: [],
stl: "none",
sdk_version: "current",
+
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.runtime",
+ "com.android.art.release", // from libdexfile_external
+ "com.android.art.debug", // from libdexfile_external
+ ],
}
-// libc_headers for libasync_safe and libpropertyinfoparser
cc_library_headers {
- name: "libc_headers",
+ // Internal lib for use in libc_headers. Since we cannot intersect arch{}
+ // and target{} in the same module, this one specifies the arch-dependent
+ // include paths, and then libc_headers filters by target so that the
+ // headers only are included for Bionic targets.
+ name: "libc_headers_arch",
+ visibility: ["//visibility:private"],
host_supported: true,
vendor_available: true,
@@ -1788,14 +1811,8 @@
"//apex_available:platform",
"//apex_available:anyapex",
],
- visibility: [
- ":__subpackages__", // visible to bionic
- // ... and only to these places (b/152668052)
- "//external/gwp_asan",
- "//external/libunwind_llvm",
- "//system/core/property_service/libpropertyinfoparser",
- "//system/extras/toolchain-extras",
- ],
+ // used by most APEXes indirectly via libunwind_llvm
+ min_sdk_version: "apex_inherit",
no_libcrt: true,
stl: "none",
@@ -1809,36 +1826,77 @@
// is correct because the headers can support any sdk_version.
sdk_version: "1",
- export_include_dirs: [
+ export_system_include_dirs: [
"include",
"kernel/uapi",
+ "kernel/android/scsi",
"kernel/android/uapi",
],
arch: {
arm: {
- export_include_dirs: [
- "kernel/uapi/asm-arm",
- ],
+ export_system_include_dirs: ["kernel/uapi/asm-arm"],
},
arm64: {
- export_include_dirs: [
- "kernel/uapi/asm-arm64",
- ],
+ export_system_include_dirs: ["kernel/uapi/asm-arm64"],
},
x86: {
- export_include_dirs: [
- "kernel/uapi/asm-x86",
- ],
+ export_system_include_dirs: ["kernel/uapi/asm-x86"],
},
x86_64: {
- export_include_dirs: [
- "kernel/uapi/asm-x86",
- ],
+ export_system_include_dirs: ["kernel/uapi/asm-x86"],
},
},
}
+cc_library_headers {
+ name: "libc_headers",
+ host_supported: true,
+ native_bridge_supported: true,
+ vendor_available: true,
+ ramdisk_available: true,
+ recovery_available: true,
+ sdk_version: "1",
+
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ // used by most APEXes indirectly via libunwind_llvm
+ min_sdk_version: "apex_inherit",
+ visibility: [
+ "//bionic:__subpackages__", // visible to bionic
+ // ... and only to these places (b/152668052)
+ "//external/arm-optimized-routines",
+ "//external/gwp_asan",
+ "//external/jemalloc_new",
+ "//external/libunwind_llvm",
+ "//external/scudo",
+ "//system/core/property_service/libpropertyinfoparser",
+ "//system/extras/toolchain-extras",
+ // TODO(b/153662223): Clean up these users that needed visibility when
+ // the implicit addition of system Bionic paths was removed.
+ "//art/tools/cpp-define-generator",
+ "//external/boringssl",
+ "//external/minijail",
+ ],
+
+ stl: "none",
+ no_libcrt: true,
+ system_shared_libs: [],
+
+ target: {
+ android: {
+ header_libs: ["libc_headers_arch"],
+ export_header_lib_headers: ["libc_headers_arch"],
+ },
+ linux_bionic: {
+ header_libs: ["libc_headers_arch"],
+ export_header_lib_headers: ["libc_headers_arch"],
+ },
+ }
+}
+
// ========================================================
// libstdc++.so and libstdc++.a.
// ========================================================
@@ -1931,7 +1989,8 @@
"//apex_available:platform",
"//apex_available:anyapex",
],
-
+ // crt* objects are used by most cc_binary/cc_library in "anyapex"
+ min_sdk_version: "apex_inherit",
cflags: [
"-Wno-gcc-compat",
"-Wall",
@@ -2485,6 +2544,11 @@
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: "29",
}
subdirs = [
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index e5e8ec3..540372b 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -34,13 +34,12 @@
#include <platform/bionic/mte_kernel.h>
extern "C" void scudo_malloc_disable_memory_tagging();
+extern "C" void scudo_malloc_set_track_allocation_stacks(int);
static HeapTaggingLevel heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
void SetDefaultHeapTaggingLevel() {
#if defined(__aarch64__)
-#define PR_SET_TAGGED_ADDR_CTRL 55
-#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
#ifdef ANDROID_EXPERIMENTAL_MTE
// First, try enabling MTE in asynchronous mode, with tag 0 excluded. This will fail if the kernel
// or hardware doesn't support MTE, and we will fall back to just enabling tagged pointers in
@@ -81,34 +80,48 @@
switch (tag_level) {
case M_HEAP_TAGGING_LEVEL_NONE:
+#if defined(USE_SCUDO)
+ scudo_malloc_disable_memory_tagging();
+#endif
+ if (heap_tagging_level == M_HEAP_TAGGING_LEVEL_TBI) {
+ __libc_globals.mutate([](libc_globals* globals) {
+ // Preserve the untag mask (we still want to untag pointers when passing them to the
+ // allocator), but clear the fixed tag and the check mask, so that pointers are no longer
+ // tagged and checks no longer happen.
+ globals->heap_pointer_tag = static_cast<uintptr_t>(0xffull << UNTAG_SHIFT);
+ });
+ }
break;
case M_HEAP_TAGGING_LEVEL_TBI:
case M_HEAP_TAGGING_LEVEL_ASYNC:
+ case M_HEAP_TAGGING_LEVEL_SYNC:
if (heap_tagging_level == M_HEAP_TAGGING_LEVEL_NONE) {
error_log(
"SetHeapTaggingLevel: re-enabling tagging after it was disabled is not supported");
- } else {
- error_log("SetHeapTaggingLevel: switching between TBI and ASYNC is not supported");
+ return false;
+ } else if (tag_level == M_HEAP_TAGGING_LEVEL_TBI ||
+ heap_tagging_level == M_HEAP_TAGGING_LEVEL_TBI) {
+ error_log("SetHeapTaggingLevel: switching between TBI and ASYNC/SYNC is not supported");
+ return false;
}
- return false;
+
+ if (tag_level == M_HEAP_TAGGING_LEVEL_ASYNC) {
+#if defined(USE_SCUDO)
+ scudo_malloc_set_track_allocation_stacks(0);
+#endif
+ } else if (tag_level == M_HEAP_TAGGING_LEVEL_SYNC) {
+#if defined(USE_SCUDO)
+ scudo_malloc_set_track_allocation_stacks(1);
+#endif
+ }
+ break;
default:
error_log("SetHeapTaggingLevel: unknown tagging level");
return false;
}
+
heap_tagging_level = tag_level;
info_log("SetHeapTaggingLevel: tag level set to %d", tag_level);
- if (heap_tagging_level == M_HEAP_TAGGING_LEVEL_NONE) {
-#if defined(USE_SCUDO)
- scudo_malloc_disable_memory_tagging();
-#endif
- __libc_globals.mutate([](libc_globals* globals) {
- // Preserve the untag mask (we still want to untag pointers when passing them to the
- // allocator if we were doing so before), but clear the fixed tag and the check mask,
- // so that pointers are no longer tagged and checks no longer happen.
- globals->heap_pointer_tag &= 0xffull << UNTAG_SHIFT;
- });
- }
-
return true;
}
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 12628f7..a47c2fc 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -52,6 +52,8 @@
#include "pthread_internal.h"
extern "C" int __system_properties_init(void);
+extern "C" void scudo_malloc_set_zero_contents(int);
+extern "C" void scudo_malloc_set_pattern_fill_contents(int);
__LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
@@ -83,6 +85,14 @@
_thread_arc4_lock();
}
+static void __libc_init_malloc_fill_contents() {
+#if defined(SCUDO_PATTERN_FILL_CONTENTS)
+ scudo_malloc_set_pattern_fill_contents(1);
+#elif defined(SCUDO_ZERO_CONTENTS)
+ scudo_malloc_set_zero_contents(1);
+#endif
+}
+
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
void __libc_add_main_thread() {
// Get the main thread from TLS and add it to the thread list.
@@ -106,6 +116,7 @@
__libc_init_fdsan(); // Requires system properties (for debug.fdsan).
__libc_init_fdtrack();
+ __libc_init_malloc_fill_contents();
SetDefaultHeapTaggingLevel();
}
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index da87c33..6a82ae3 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -366,6 +366,9 @@
return true;
}
+extern "C" const char* __scudo_get_stack_depot_addr();
+extern "C" const char* __scudo_get_region_info_addr();
+
// Initializes memory allocation framework once per process.
static void MallocInitImpl(libc_globals* globals) {
char prop[PROP_VALUE_MAX];
@@ -373,6 +376,11 @@
MaybeInitGwpAsanFromLibc(globals);
+#if defined(USE_SCUDO)
+ __libc_shared_globals()->scudo_stack_depot = __scudo_get_stack_depot_addr();
+ __libc_shared_globals()->scudo_region_info = __scudo_get_region_info_addr();
+#endif
+
// Prefer malloc debug since it existed first and is a more complete
// malloc interceptor than the hooks.
bool hook_installed = false;
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 1b8af78..50cb61a 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -110,6 +110,9 @@
/** Names the "R" API level (30), for comparison against `__ANDROID_API__`. */
#define __ANDROID_API_R__ 30
+/** Names the "S" API level (31), for comparison against `__ANDROID_API__`. */
+#define __ANDROID_API_S__ 31
+
/**
* Returns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__`
* if there is no known target SDK version (for code not running in the
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 2284775..10732a1 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1550,7 +1550,7 @@
_Unwind_VRS_Set; # apex llndk arm
} LIBC_Q;
-LIBC_S { # introduced=31
+LIBC_S { # introduced=S
global:
ffsl;
ffsll;
diff --git a/libc/platform/bionic/malloc.h b/libc/platform/bionic/malloc.h
index 0ea7e3c..f9eb03f 100644
--- a/libc/platform/bionic/malloc.h
+++ b/libc/platform/bionic/malloc.h
@@ -116,6 +116,8 @@
M_HEAP_TAGGING_LEVEL_TBI = 1,
// Enable heap tagging if supported, at a level appropriate for asynchronous memory tag checks.
M_HEAP_TAGGING_LEVEL_ASYNC = 2,
+ // Enable heap tagging if supported, at a level appropriate for synchronous memory tag checks.
+ M_HEAP_TAGGING_LEVEL_SYNC = 3,
};
// Manipulates bionic-specific handling of memory allocation APIs such as
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index 54605db..5c9b726 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -103,6 +103,9 @@
const gwp_asan::AllocatorState* gwp_asan_state = nullptr;
const gwp_asan::AllocationMetadata* gwp_asan_metadata = nullptr;
+
+ const char* scudo_stack_depot = nullptr;
+ const char* scudo_region_info = nullptr;
};
__LIBC_HIDDEN__ libc_shared_globals* __libc_shared_globals();
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 8e3a3fc..6a3a82e 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -25,6 +25,8 @@
stl: "none",
system_shared_libs: [],
+ header_libs: ["libc_headers"],
+ export_header_lib_headers: ["libc_headers"],
sanitize: {
never: true,
@@ -97,6 +99,7 @@
nocrt: true,
system_shared_libs: [],
+ header_libs: ["libc_headers"],
// Opt out of native_coverage when opting out of system_shared_libs
native_coverage: false,
@@ -175,6 +178,7 @@
nocrt: true,
system_shared_libs: [],
+ header_libs: ["libc_headers"],
// Opt out of native_coverage when opting out of system_shared_libs
native_coverage: false,
diff --git a/linker/Android.bp b/linker/Android.bp
index 4be080b..1792c74 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -46,6 +46,8 @@
prefix_symbols: "__dlwrap_",
+ header_libs: ["libc_headers"],
+
// We need to access Bionic private headers in the linker.
include_dirs: ["bionic/libc"],
}
@@ -404,6 +406,7 @@
nocrt: true,
system_shared_libs: [],
+ header_libs: ["libc_headers"],
// Opt out of native_coverage when opting out of system_shared_libs
native_coverage: false,
diff --git a/linker/linker.cpp b/linker/linker.cpp
index e34c796..b368e96 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -103,7 +103,7 @@
static const char* const kAsanSystemLibDir = "/data/asan/system/lib64";
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib64";
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib64";
-static const char* const kArtApexLibDir = "/apex/com.android.art/lib64";
+static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib64";
#else
static const char* const kSystemLibDir = "/system/lib";
static const char* const kOdmLibDir = "/odm/lib";
@@ -111,7 +111,7 @@
static const char* const kAsanSystemLibDir = "/data/asan/system/lib";
static const char* const kAsanOdmLibDir = "/data/asan/odm/lib";
static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib";
-static const char* const kArtApexLibDir = "/apex/com.android.art/lib";
+static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib";
#endif
static const char* const kAsanLibDirPrefix = "/data/asan";
@@ -264,7 +264,7 @@
for (const char* soname : kSystemToArtApexLibs) {
if (strcmp(base_name, soname) == 0) {
- *out_name_to_apex = std::string(kArtApexLibDir) + "/" + base_name;
+ *out_name_to_apex = std::string(kI18nApexLibDir) + "/" + base_name;
return true;
}
}
diff --git a/linker/linker_debuggerd_android.cpp b/linker/linker_debuggerd_android.cpp
index 6a81673..203e441 100644
--- a/linker/linker_debuggerd_android.cpp
+++ b/linker/linker_debuggerd_android.cpp
@@ -40,6 +40,8 @@
.fdsan_table = &__libc_shared_globals()->fd_table,
.gwp_asan_state = __libc_shared_globals()->gwp_asan_state,
.gwp_asan_metadata = __libc_shared_globals()->gwp_asan_metadata,
+ .scudo_stack_depot = __libc_shared_globals()->scudo_stack_depot,
+ .scudo_region_info = __libc_shared_globals()->scudo_region_info,
};
}
#endif
diff --git a/tests/Android.bp b/tests/Android.bp
index c751084..598865b 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -22,6 +22,12 @@
darwin: {
enabled: false,
},
+ android: {
+ header_libs: ["bionic_libc_platform_headers"],
+ },
+ linux_bionic: {
+ header_libs: ["bionic_libc_platform_headers"],
+ },
},
cflags: [
"-fstack-protector-all",
@@ -38,7 +44,6 @@
// For glibc.
"-D__STDC_LIMIT_MACROS",
],
- header_libs: ["bionic_libc_platform_headers"],
// Ensure that the tests exercise shadow call stack support and
// the hint space PAC/BTI instructions.
arch: {
@@ -117,6 +122,7 @@
"glob_test.cpp",
"grp_pwd_test.cpp",
"grp_pwd_file_test.cpp",
+ "heap_tagging_level_test.cpp",
"iconv_test.cpp",
"ifaddrs_test.cpp",
"ifunc_test.cpp",
@@ -231,9 +237,6 @@
"libprocinfo",
"libsystemproperties",
],
- srcs: [
- "tagged_pointers_test.cpp",
- ],
},
},
diff --git a/tests/android_get_device_api_level.cpp b/tests/android_get_device_api_level.cpp
index 0662404..9bd6b3a 100644
--- a/tests/android_get_device_api_level.cpp
+++ b/tests/android_get_device_api_level.cpp
@@ -35,6 +35,6 @@
TEST(android_get_device_api_level, smoke) {
#if __BIONIC__
// This will fail if you run the tests on an old device, but who does that?
- ASSERT_GE(29, android_get_device_api_level());
+ ASSERT_GE(android_get_device_api_level(), 29);
#endif
}
diff --git a/tests/clang_fortify_tests.cpp b/tests/clang_fortify_tests.cpp
index 018880f..715f9c8 100644
--- a/tests/clang_fortify_tests.cpp
+++ b/tests/clang_fortify_tests.cpp
@@ -167,6 +167,8 @@
EXPECT_FORTIFY_DEATH(memcpy(small_buffer, large_buffer, sizeof(large_buffer)));
// expected-error@+1{{will always overflow}}
EXPECT_FORTIFY_DEATH(memmove(small_buffer, large_buffer, sizeof(large_buffer)));
+ // FIXME(gbiv): look into removing mempcpy's diagnose_if bits once the b/149839606 roll sticks.
+ // expected-error@+2{{will always overflow}}
// expected-error@+1{{size bigger than buffer}}
EXPECT_FORTIFY_DEATH(mempcpy(small_buffer, large_buffer, sizeof(large_buffer)));
// expected-error@+1{{will always overflow}}
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 293c17b..1139e53 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -237,6 +237,24 @@
ASSERT_TRUE(dlopen(nullptr, RTLD_NOW) != nullptr);
}
+// Test system path translation for backward compatibility. http://b/130219528
+TEST(dlfcn, dlopen_system_libicuuc_android_api_level_28) {
+ android_set_application_target_sdk_version(28);
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicuuc.so", RTLD_NOW) != nullptr);
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicui18n.so", RTLD_NOW) != nullptr);
+}
+
+TEST(dlfcn, dlopen_system_libicuuc_android_api_level_29) {
+ android_set_application_target_sdk_version(29);
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicuuc.so", RTLD_NOW) == nullptr);
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicui18n.so", RTLD_NOW) == nullptr);
+}
+
+TEST(dlfcn, dlopen_system_libicuuc_android_api_level_current) {
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicuuc.so", RTLD_NOW) == nullptr);
+ ASSERT_TRUE(dlopen(PATH_TO_SYSTEM_LIB "libicui18n.so", RTLD_NOW) == nullptr);
+}
+
TEST(dlfcn, dlopen_from_zip_absolute_path) {
const std::string lib_zip_path = "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip";
const std::string lib_path = GetTestlibRoot() + lib_zip_path;
diff --git a/tests/fdtrack_test.cpp b/tests/fdtrack_test.cpp
index 44aa033..fe9a61c 100644
--- a/tests/fdtrack_test.cpp
+++ b/tests/fdtrack_test.cpp
@@ -29,11 +29,13 @@
#if defined(__BIONIC__)
#include "platform/bionic/fdtrack.h"
+#include "platform/bionic/reserved_signals.h"
#endif
#include <vector>
#include <android-base/cmsg.h>
+#include <android-base/logging.h>
#include <android-base/unique_fd.h>
using android::base::ReceiveFileDescriptors;
@@ -41,6 +43,18 @@
using android::base::unique_fd;
#if defined(__BIONIC__)
+void DumpEvent(std::vector<android_fdtrack_event>* events, size_t index) {
+ auto& event = (*events)[index];
+ if (event.type == ANDROID_FDTRACK_EVENT_TYPE_CREATE) {
+ fprintf(stderr, " event %zu: fd %d created by %s\n", index, event.fd,
+ event.data.create.function_name);
+ } else if (event.type == ANDROID_FDTRACK_EVENT_TYPE_CLOSE) {
+ fprintf(stderr, " event %zu: fd %d closed\n", index, event.fd);
+ } else {
+ errx(1, "unexpected fdtrack event type: %d", event.type);
+ }
+}
+
std::vector<android_fdtrack_event> FdtrackRun(void (*func)()) {
// Each bionic test is run in separate process, so we can safely use a static here.
static std::vector<android_fdtrack_event> events;
@@ -48,6 +62,7 @@
android_fdtrack_hook_t previous = nullptr;
android_fdtrack_hook_t hook = [](android_fdtrack_event* event) {
+ raise(BIONIC_SIGNAL_DEBUGGER);
events.push_back(*event);
};
@@ -66,6 +81,30 @@
errx(1, "failed to reset hook");
}
+ // Filter out temporary fds created and closed as a result of the call.
+ // (e.g. accept creating a socket to tell netd about the newly accepted socket)
+ size_t i = 0;
+ while (i + 1 < events.size()) {
+ auto& event = events[i];
+ if (event.type == ANDROID_FDTRACK_EVENT_TYPE_CREATE) {
+ for (size_t j = i + 1; j < events.size(); ++j) {
+ if (event.fd == events[j].fd) {
+ if (events[j].type == ANDROID_FDTRACK_EVENT_TYPE_CREATE) {
+ fprintf(stderr, "error: multiple create events for the same fd:\n");
+ DumpEvent(&events, i);
+ DumpEvent(&events, j);
+ exit(1);
+ }
+
+ events.erase(events.begin() + j);
+ events.erase(events.begin() + i);
+ continue;
+ }
+ }
+ }
+ ++i;
+ }
+
return std::move(events);
}
@@ -146,15 +185,7 @@
fprintf(stderr, "too many events received: expected %zu, got %zu:\n", expected_fds.size(), \
events.size()); \
for (size_t i = 0; i < events.size(); ++i) { \
- auto& event = events[i]; \
- if (event.type == ANDROID_FDTRACK_EVENT_TYPE_CREATE) { \
- fprintf(stderr, " event %zu: fd %d created by %s\n", i, event.fd, \
- event.data.create.function_name); \
- } else if (event.type == ANDROID_FDTRACK_EVENT_TYPE_CLOSE) { \
- fprintf(stderr, " event %zu: fd %d closed\n", i, event.fd); \
- } else { \
- errx(1, "unexpected fdtrack event type: %d", event.type); \
- } \
+ DumpEvent(&events, i); \
} \
FAIL(); \
return; \
@@ -216,12 +247,11 @@
FDTRACK_TEST(eventfd, eventfd(0, 0));
-#if 0
-// Why is this generating an extra socket/close event?
-FDTRACK_TEST(accept, ({
+#if defined(__BIONIC__)
+static int CreateListener() {
android_fdtrack_set_enabled(false);
int listener = socket(AF_INET, SOCK_STREAM, 0);
- ASSERT_NE(-1, listener);
+ CHECK_NE(-1, listener);
sockaddr_in addr = {
.sin_family = AF_INET,
@@ -230,21 +260,23 @@
};
socklen_t addrlen = sizeof(addr);
- ASSERT_NE(-1, bind(listener, reinterpret_cast<sockaddr*>(&addr), addrlen)) << strerror(errno);
- ASSERT_NE(-1, getsockname(listener, reinterpret_cast<sockaddr*>(&addr), &addrlen));
- ASSERT_EQ(static_cast<size_t>(addrlen), sizeof(addr));
- ASSERT_NE(-1, listen(listener, 1));
+ CHECK_NE(-1, bind(listener, reinterpret_cast<sockaddr*>(&addr), addrlen)) << strerror(errno);
+ CHECK_NE(-1, getsockname(listener, reinterpret_cast<sockaddr*>(&addr), &addrlen));
+ CHECK_EQ(static_cast<size_t>(addrlen), sizeof(addr));
+ CHECK_NE(-1, listen(listener, 1));
int connector = socket(AF_INET, SOCK_STREAM, 0);
- ASSERT_NE(-1, connector);
- ASSERT_NE(-1, connect(connector, reinterpret_cast<sockaddr*>(&addr), addrlen));
-
+ CHECK_NE(-1, connector);
+ CHECK_NE(-1, connect(connector, reinterpret_cast<sockaddr*>(&addr), addrlen));
android_fdtrack_set_enabled(true);
- int accepted = accept(listener, nullptr, nullptr);
- accepted;
-}));
+
+ return listener;
+}
#endif
+FDTRACK_TEST_NAME(accept, "accept4", accept(CreateListener(), nullptr, nullptr));
+FDTRACK_TEST(accept4, accept4(CreateListener(), nullptr, nullptr, 0));
+
FDTRACK_TEST(recvmsg, ({
android_fdtrack_set_enabled(false);
int sockets[2];
diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp
new file mode 100644
index 0000000..05123fd
--- /dev/null
+++ b/tests/heap_tagging_level_test.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <gtest/gtest.h>
+#include <sys/prctl.h>
+
+#if defined(__BIONIC__)
+#include "platform/bionic/malloc.h"
+#include "platform/bionic/mte.h"
+#include "utils.h"
+
+#include "SignalUtils.h"
+
+#include <bionic/malloc_tagged_pointers.h>
+
+static bool KernelSupportsTaggedPointers() {
+#ifdef __aarch64__
+ int res = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
+ return res >= 0 && res & PR_TAGGED_ADDR_ENABLE;
+#else
+ return false;
+#endif
+}
+
+static bool SetHeapTaggingLevel(HeapTaggingLevel level) {
+ return android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &level, sizeof(level));
+}
+#endif
+
+TEST(heap_tagging_level, tagged_pointer_dies) {
+#if defined(__BIONIC__)
+ if (!KernelSupportsTaggedPointers()) {
+ GTEST_SKIP() << "Kernel doesn't support tagged pointers.";
+ }
+
+#ifdef __aarch64__
+ if (mte_supported()) {
+ GTEST_SKIP() << "Tagged pointers are not used on MTE hardware.";
+ }
+
+ void *x = malloc(1);
+
+ // Ensure that `x` has a pointer tag.
+ EXPECT_NE(reinterpret_cast<uintptr_t>(x) >> 56, 0u);
+
+ x = untag_address(x);
+ EXPECT_DEATH(free(x), "Pointer tag for 0x[a-zA-Z0-9]* was truncated");
+
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
+ EXPECT_DEATH(free(untag_address(malloc(1))), "Pointer tag for 0x[a-zA-Z0-9]* was truncated");
+
+ x = malloc(1);
+ void *y = malloc(1);
+ // Disable heap tagging.
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
+ // Ensure an older tagged pointer can still be freed.
+ free(x);
+ // Tag mismatch is not detected on old pointers.
+ free(untag_address(y));
+#endif // defined(__aarch64__)
+#else
+ GTEST_SKIP() << "bionic-only test";
+#endif // defined(__BIONIC__)
+}
+
+#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+template <int SiCode> void CheckSiCode(int, siginfo_t* info, void*) {
+ if (info->si_code != SiCode) {
+ _exit(2);
+ }
+ _exit(1);
+}
+
+static bool SetTagCheckingLevel(int level) {
+ int tagged_addr_ctrl = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
+ if (tagged_addr_ctrl < 0) {
+ return false;
+ }
+
+ tagged_addr_ctrl = (tagged_addr_ctrl & ~PR_MTE_TCF_MASK) | level;
+ return prctl(PR_SET_TAGGED_ADDR_CTRL, tagged_addr_ctrl, 0, 0, 0) == 0;
+}
+#endif
+
+TEST(heap_tagging_level, sync_async_bad_accesses_die) {
+#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+ if (!(getauxval(AT_HWCAP2) & HWCAP2_MTE)) {
+ GTEST_SKIP() << "requires MTE support";
+ }
+
+ std::unique_ptr<int[]> p = std::make_unique<int[]>(4);
+
+ // First, check that memory tagging is enabled and the default tag checking level is async.
+ // We assume that scudo is used on all MTE enabled hardware; scudo inserts a header with a
+ // mismatching tag before each allocation.
+ EXPECT_EXIT(
+ {
+ ScopedSignalHandler ssh(SIGSEGV, CheckSiCode<SEGV_MTEAERR>, SA_SIGINFO);
+ p[-1] = 42;
+ },
+ testing::ExitedWithCode(1), "");
+
+ EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_SYNC));
+ EXPECT_EXIT(
+ {
+ ScopedSignalHandler ssh(SIGSEGV, CheckSiCode<SEGV_MTESERR>, SA_SIGINFO);
+ p[-1] = 42;
+ },
+ testing::ExitedWithCode(1), "");
+
+ EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_NONE));
+ volatile int oob ATTRIBUTE_UNUSED = p[-1];
+#endif
+}
+
+TEST(heap_tagging_level, none_pointers_untagged) {
+#if defined(__BIONIC__)
+#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
+ EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_NONE));
+#endif
+
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
+ std::unique_ptr<int[]> p = std::make_unique<int[]>(4);
+ EXPECT_EQ(untag_address(p.get()), p.get());
+#else
+ GTEST_SKIP() << "bionic-only test";
+#endif
+}
+
+TEST(heap_tagging_level, tagging_level_transitions) {
+#if defined(__BIONIC__) && defined(__aarch64__)
+ if (!KernelSupportsTaggedPointers()) {
+ GTEST_SKIP() << "Kernel doesn't support tagged pointers.";
+ }
+
+#if defined(ANDROID_EXPERIMENTAL_MTE)
+ EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_NONE));
+#endif
+
+ EXPECT_FALSE(SetHeapTaggingLevel(static_cast<HeapTaggingLevel>(12345)));
+
+ if (mte_supported()) {
+ // ASYNC -> ...
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
+
+ // SYNC -> ...
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
+ } else {
+ // TBI -> ...
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
+ }
+
+ // TBI -> NONE on non-MTE, ASYNC -> NONE on MTE.
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
+
+ // NONE -> ...
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
+ EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
+#else
+ GTEST_SKIP() << "bionic/arm64 only";
+#endif
+}
+
+TEST(heap_tagging_level, tagging_level_transition_sync_none) {
+#if defined(__BIONIC__) && defined(__aarch64__)
+ // We can't test SYNC -> NONE in tagging_level_transitions because we can only make one transition
+ // to NONE (which we use to test ASYNC -> NONE), so we test it here separately.
+ if (!mte_supported()) {
+ GTEST_SKIP() << "requires MTE support";
+ }
+
+#if defined(ANDROID_EXPERIMENTAL_MTE)
+ EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_NONE));
+#endif
+
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
+ EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
+#else
+ GTEST_SKIP() << "bionic/arm64 only";
+#endif
+}
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index a2f310e..47a9033 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -1201,69 +1201,3 @@
GTEST_SKIP() << "bionic extension";
#endif
}
-
-#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
-template <int SiCode> void CheckSiCode(int, siginfo_t* info, void*) {
- if (info->si_code != SiCode) {
- _exit(2);
- }
- _exit(1);
-}
-
-static bool SetTagCheckingLevel(int level) {
- int tagged_addr_ctrl = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
- if (tagged_addr_ctrl < 0) {
- return false;
- }
-
- tagged_addr_ctrl = (tagged_addr_ctrl & ~PR_MTE_TCF_MASK) | level;
- return prctl(PR_SET_TAGGED_ADDR_CTRL, tagged_addr_ctrl, 0, 0, 0) == 0;
-}
-#endif
-
-TEST(android_mallopt, tag_level) {
-#if defined(__BIONIC__) && defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
- if (!(getauxval(AT_HWCAP2) & HWCAP2_MTE)) {
- GTEST_SKIP() << "requires MTE support";
- }
-
- std::unique_ptr<int[]> p = std::make_unique<int[]>(4);
-
- // First, check that memory tagging is enabled and the default tag checking level is async.
- // We assume that scudo is used on all MTE enabled hardware; scudo inserts a header with a
- // mismatching tag before each allocation.
- EXPECT_EXIT(
- {
- ScopedSignalHandler ssh(SIGSEGV, CheckSiCode<SEGV_MTEAERR>, SA_SIGINFO);
- p[-1] = 42;
- },
- testing::ExitedWithCode(1), "");
-
- EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_SYNC));
- EXPECT_EXIT(
- {
- ScopedSignalHandler ssh(SIGSEGV, CheckSiCode<SEGV_MTESERR>, SA_SIGINFO);
- p[-1] = 42;
- },
- testing::ExitedWithCode(1), "");
-
- EXPECT_TRUE(SetTagCheckingLevel(PR_MTE_TCF_NONE));
- volatile int oob ATTRIBUTE_UNUSED = p[-1];
-
- HeapTaggingLevel tag_level = M_HEAP_TAGGING_LEVEL_TBI;
- EXPECT_FALSE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
-
- tag_level = M_HEAP_TAGGING_LEVEL_NONE;
- EXPECT_TRUE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
- std::unique_ptr<int[]> p2 = std::make_unique<int[]>(4);
- EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(p2.get()) >> 56);
-
- tag_level = M_HEAP_TAGGING_LEVEL_ASYNC;
- EXPECT_FALSE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
-
- tag_level = M_HEAP_TAGGING_LEVEL_NONE;
- EXPECT_TRUE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
-#else
- GTEST_SKIP() << "arm64 only";
-#endif
-}
diff --git a/tests/mte_test.cpp b/tests/mte_test.cpp
index 8928805..ff8cde6 100644
--- a/tests/mte_test.cpp
+++ b/tests/mte_test.cpp
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+#include <sys/cdefs.h>
+
+#if defined(__BIONIC__)
+
#include <gtest/gtest.h>
#include <android-base/macros.h>
@@ -46,3 +50,5 @@
TEST(mte_test, ScopedDisableMTE) {
test_tag_mismatch();
}
+
+#endif // __BIONIC__
diff --git a/tests/tagged_pointers_test.cpp b/tests/tagged_pointers_test.cpp
deleted file mode 100644
index 56d1037..0000000
--- a/tests/tagged_pointers_test.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-#include <gtest/gtest.h>
-#include <sys/prctl.h>
-
-#include "platform/bionic/malloc.h"
-#include "platform/bionic/mte.h"
-#include "utils.h"
-
-#include <bionic/malloc_tagged_pointers.h>
-
-static bool KernelSupportsTaggedPointers() {
-#ifdef __aarch64__
-#define PR_SET_TAGGED_ADDR_CTRL 55
-#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
- int res = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
- return res >= 0 && res & PR_TAGGED_ADDR_ENABLE;
-#else
- return false;
-#endif
-}
-
-TEST(tagged_pointers, check_tagged_pointer_dies) {
- if (!KernelSupportsTaggedPointers()) {
- GTEST_SKIP() << "Kernel doesn't support tagged pointers.";
- }
-
-#ifdef __aarch64__
- if (mte_supported()) {
- GTEST_SKIP() << "Tagged pointers are not used on MTE hardware.";
- }
-
- void *x = malloc(1);
-
- // Ensure that `x` has a pointer tag.
- EXPECT_NE(reinterpret_cast<uintptr_t>(x) >> 56, 0u);
-
- x = untag_address(x);
- EXPECT_DEATH(free(x), "Pointer tag for 0x[a-zA-Z0-9]* was truncated");
-
- HeapTaggingLevel tag_level = M_HEAP_TAGGING_LEVEL_TBI;
- EXPECT_TRUE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
- EXPECT_DEATH(free(untag_address(malloc(1))), "Pointer tag for 0x[a-zA-Z0-9]* was truncated");
-
- tag_level = M_HEAP_TAGGING_LEVEL_ASYNC;
- EXPECT_FALSE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
-
- x = malloc(1);
- void *y = malloc(1);
- // Disable heap tagging.
- tag_level = M_HEAP_TAGGING_LEVEL_NONE;
- EXPECT_TRUE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
- // Ensure an older tagged pointer can still be freed.
- free(x);
- // Tag mismatch is not detected on old pointers.
- free(untag_address(y));
- // New pointers are not tagged.
- x = malloc(1);
- EXPECT_EQ(untag_address(x), x);
- free(x);
-
- // Switching back to checked mode is not possible.
- tag_level = M_HEAP_TAGGING_LEVEL_TBI;
- EXPECT_FALSE(android_mallopt(M_SET_HEAP_TAGGING_LEVEL, &tag_level, sizeof(tag_level)));
- // We remain in the unchecked mode.
- x = malloc(1);
- EXPECT_EQ(untag_address(x), x);
- free(x);
-#endif // defined(__aarch64__)
-}
diff --git a/tests/utils.h b/tests/utils.h
index 5085a7a..a9b8513 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -25,7 +25,11 @@
#include <sys/wait.h>
#include <unistd.h>
+#if defined(__BIONIC__)
#include <bionic/macros.h>
+#else
+#define untag_address(p) p
+#endif
#include <atomic>
#include <string>
diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp
index 3c6f643..b41c865 100644
--- a/tools/versioner/src/DeclarationDatabase.cpp
+++ b/tools/versioner/src/DeclarationDatabase.cpp
@@ -72,7 +72,7 @@
// <math.h> maps fool onto foo on 32-bit, since long double is the same as double.
if (auto asm_attr = decl->getAttr<AsmLabelAttr>()) {
- return asm_attr->getLabel();
+ return asm_attr->getLabel().str();
}
// The decl might not have a name (e.g. bitfields).
@@ -84,7 +84,7 @@
return mangled;
}
- return identifier->getName();
+ return identifier->getName().str();
}
return "<unnamed>";
@@ -173,7 +173,7 @@
&arch_availability[Arch::x86_64].introduced } },
};
- if (auto it = prefix_map.find(fragments[0]); it != prefix_map.end()) {
+ if (auto it = prefix_map.find(fragments[0].str()); it != prefix_map.end()) {
int value;
if (fragments[1].getAsInteger(10, value)) {
errx(1, "invalid __ANDROID_AVAILABILITY_DUMP__ annotation: '%s'",
@@ -201,7 +201,7 @@
}
Location location = {
- .filename = filename,
+ .filename = filename.str(),
.start = {
.line = src_manager.getExpansionLineNumber(expansion_range.getBegin()),
.column = src_manager.getExpansionColumnNumber(expansion_range.getBegin()),
diff --git a/tools/versioner/src/Preprocessor.cpp b/tools/versioner/src/Preprocessor.cpp
index 4ee3446..7a5b502 100644
--- a/tools/versioner/src/Preprocessor.cpp
+++ b/tools/versioner/src/Preprocessor.cpp
@@ -446,7 +446,7 @@
continue;
}
- std::string rel_path = path.substr(src_dir.length() + 1);
+ std::string rel_path = path.substr(src_dir.length() + 1).str();
std::string dst_path = dst_dir + "/" + rel_path;
llvm::StringRef parent_path = llvm::sys::path::parent_path(dst_path);
if (llvm::sys::fs::create_directories(parent_path)) {
@@ -471,13 +471,13 @@
GuardMap guard_map;
for (const auto& it : orig_guard_map) {
Location loc = it.first;
- loc.end = findNextSemicolon(file_lines[file_path], loc.end);
+ loc.end = findNextSemicolon(file_lines[file_path.str()], loc.end);
guard_map[loc] = it.second;
}
// TODO: Make sure that the Locations don't overlap.
// TODO: Merge adjacent non-identical guards.
- mergeGuards(file_lines[file_path], guard_map);
+ mergeGuards(file_lines[file_path.str()], guard_map);
if (!file_path.startswith(src_dir)) {
errx(1, "input file %s is not in %s\n", file_path.str().c_str(), src_dir.c_str());
@@ -487,7 +487,7 @@
llvm::StringRef rel_path = file_path.substr(src_dir.size(), file_path.size() - src_dir.size());
std::string output_path = (llvm::Twine(dst_dir) + rel_path).str();
- rewriteFile(output_path, file_lines[file_path], guard_map);
+ rewriteFile(output_path, file_lines[file_path.str()], guard_map);
}
return true;