Merge "Finalize the name of the apex package"
diff --git a/benchmarks/tests/interface_test.cpp b/benchmarks/tests/interface_test.cpp
index ff4b255..301c294 100644
--- a/benchmarks/tests/interface_test.cpp
+++ b/benchmarks/tests/interface_test.cpp
@@ -63,7 +63,7 @@
void SystemTests::SanitizeOutput() {
// Cut off anything after the arguments, since that varies with time.
- sanitized_output_ = std::regex_replace(raw_output_, std::regex(".+(BM_\\S+) +.+"), "$1");
+ sanitized_output_ = std::regex_replace(raw_output_, std::regex(".*(BM_\\S+)\\s+.+"), "$1");
// Remove everything before the header.
sanitized_output_.erase(0, sanitized_output_.find("------------------------------------------------"));
@@ -165,7 +165,8 @@
" [--benchmark_filter=<regex>]\n"
" [--benchmark_min_time=<min_time>]\n"
" [--benchmark_repetitions=<num_repetitions>]\n"
- " [--benchmark_report_aggregates_only={true|false}\n"
+ " [--benchmark_report_aggregates_only={true|false}]\n"
+ " [--benchmark_display_aggregates_only={true|false}]\n"
" [--benchmark_format=<console|json|csv>]\n"
" [--benchmark_out=<filename>]\n"
" [--benchmark_out_format=<json|console|csv>]\n"
diff --git a/libc/include/android/dlext.h b/libc/include/android/dlext.h
index 431e5ce..e78be39 100644
--- a/libc/include/android/dlext.h
+++ b/libc/include/android/dlext.h
@@ -100,34 +100,11 @@
*/
ANDROID_DLEXT_FORCE_LOAD = 0x40,
- /**
- * When set, if the minimum `p_vaddr` of the ELF file's `PT_LOAD` segments is non-zero,
- * the dynamic linker will load it at that address.
- *
- * This flag is for ART internal use only.
- */
- ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80,
-
- /**
- * Instructs dlopen to load the library at the address specified by reserved_addr.
- *
- * The difference between `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` and
- * `ANDROID_DLEXT_RESERVED_ADDRESS` is that for `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` the linker
- * reserves memory at `reserved_addr` whereas for `ANDROID_DLEXT_RESERVED_ADDRESS` the linker
- * relies on the caller to reserve the memory.
- *
- * This flag can be used with `ANDROID_DLEXT_FORCE_FIXED_VADDR`. When
- * `ANDROID_DLEXT_FORCE_FIXED_VADDR` is set and `load_bias` is not 0 (`load_bias` is the
- * minimum `p_vaddr` of all `PT_LOAD` segments) this flag is ignored because the linker has to
- * pick one address over the other and this way is more convenient for ART.
- * Note that `ANDROID_DLEXT_FORCE_FIXED_VADDR` does not generate an error when the minimum
- * `p_vaddr` is 0.
- *
- * Cannot be used with `ANDROID_DLEXT_RESERVED_ADDRESS` or `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`.
- *
- * This flag is for ART internal use only.
- */
- ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 0x100,
+ // Historically we had two other options for ART.
+ // They were last available in Android P.
+ // Reuse these bits last!
+ // ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80
+ // ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 0x100
/**
* This flag used to load library in a different namespace. The namespace is
@@ -145,8 +122,6 @@
ANDROID_DLEXT_USE_LIBRARY_FD |
ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET |
ANDROID_DLEXT_FORCE_LOAD |
- ANDROID_DLEXT_FORCE_FIXED_VADDR |
- ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS |
ANDROID_DLEXT_USE_NAMESPACE,
};
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index 01f42b7..0961a94 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -63,11 +63,6 @@
},
},
- // Clang lld link flags do not work with special link rules
- // for libunwind_llvm yet. Linked aosp_arm-eng image failed to
- // boot up in the emulator. http://b/78118944.
- use_clang_lld: false,
-
static_libs: [
"libasync_safe",
"libbase",
diff --git a/linker/Android.bp b/linker/Android.bp
index 779cd3f..8ef540c 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -167,10 +167,6 @@
"-Wl,-soname,ld-android.so",
],
- // lld bug: https://bugs.llvm.org/show_bug.cgi?id=36295
- // error: symbol __aeabi_*@@LIBC_N has undefined version LIBC_N
- use_clang_lld: false,
-
cflags: [
"-fno-stack-protector",
"-Wstrict-overflow=5",
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 0470d7a..7993681 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2074,13 +2074,6 @@
return nullptr;
}
- if ((extinfo->flags & ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS) != 0 &&
- (extinfo->flags & (ANDROID_DLEXT_RESERVED_ADDRESS | ANDROID_DLEXT_RESERVED_ADDRESS_HINT)) != 0) {
- DL_ERR("invalid extended flag combination: ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS is not "
- "compatible with ANDROID_DLEXT_RESERVED_ADDRESS/ANDROID_DLEXT_RESERVED_ADDRESS_HINT");
- return nullptr;
- }
-
if ((extinfo->flags & ANDROID_DLEXT_USE_NAMESPACE) != 0) {
if (extinfo->library_namespace == nullptr) {
DL_ERR("ANDROID_DLEXT_USE_NAMESPACE is set but extinfo->library_namespace is null");
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 8bf4c94..0123d3c 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -525,14 +525,10 @@
// Reserve a virtual address range such that if it's limits were extended to the next 2**align
// boundary, it would not overlap with any existing mappings.
-static void* ReserveAligned(void* hint, size_t size, size_t align) {
+static void* ReserveAligned(size_t size, size_t align) {
int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
- // Address hint is only used in Art for the image mapping, and it is pretty important. Don't mess
- // with it.
- // FIXME: try an aligned allocation and fall back to plain mmap() if the former does not provide a
- // mapping at the requested address?
- if (align == PAGE_SIZE || hint != nullptr) {
- void* mmap_ptr = mmap(hint, size, PROT_NONE, mmap_flags, -1, 0);
+ if (align == PAGE_SIZE) {
+ void* mmap_ptr = mmap(nullptr, size, PROT_NONE, mmap_flags, -1, 0);
if (mmap_ptr == MAP_FAILED) {
return nullptr;
}
@@ -575,9 +571,6 @@
void* start;
size_t reserved_size = 0;
bool reserved_hint = true;
- bool strict_hint = false;
- // Assume position independent executable by default.
- void* mmap_hint = nullptr;
if (extinfo != nullptr) {
if (extinfo->flags & ANDROID_DLEXT_RESERVED_ADDRESS) {
@@ -586,13 +579,6 @@
} else if (extinfo->flags & ANDROID_DLEXT_RESERVED_ADDRESS_HINT) {
reserved_size = extinfo->reserved_size;
}
-
- if (addr != nullptr && (extinfo->flags & ANDROID_DLEXT_FORCE_FIXED_VADDR) != 0) {
- mmap_hint = addr;
- } else if ((extinfo->flags & ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS) != 0) {
- mmap_hint = extinfo->reserved_addr;
- strict_hint = true;
- }
}
if (load_size_ > reserved_size) {
@@ -601,17 +587,11 @@
reserved_size - load_size_, load_size_, name_.c_str());
return false;
}
- start = ReserveAligned(mmap_hint, load_size_, kLibraryAlignment);
+ start = ReserveAligned(load_size_, kLibraryAlignment);
if (start == nullptr) {
DL_ERR("couldn't reserve %zd bytes of address space for \"%s\"", load_size_, name_.c_str());
return false;
}
- if (strict_hint && (start != mmap_hint)) {
- munmap(start, load_size_);
- DL_ERR("couldn't reserve %zd bytes of address space at %p for \"%s\"",
- load_size_, mmap_hint, name_.c_str());
- return false;
- }
} else {
start = extinfo->reserved_addr;
mapped_by_caller_ = true;
diff --git a/tests/buffer_tests.cpp b/tests/buffer_tests.cpp
index a5a0c2a..7563448 100644
--- a/tests/buffer_tests.cpp
+++ b/tests/buffer_tests.cpp
@@ -227,6 +227,18 @@
}
}
+// Malloc can return a tagged pointer, which is not accepted in mm system calls like mprotect.
+// Clear top 8 bits of the address on 64-bit platforms.
+static int MprotectHeap(void* addr, size_t len, int prot) {
+#if defined(__LP64__)
+ constexpr uintptr_t mask = (static_cast<uintptr_t>(1) << 56) - 1;
+ void* untagged_addr = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) & mask);
+#else
+ void* untagged_addr = addr;
+#endif
+ return mprotect(untagged_addr, len, prot);
+}
+
void RunSingleBufferAlignTest(
size_t max_test_size, void (*test_func)(uint8_t*, size_t),
size_t (*set_incr)(size_t)) {
@@ -358,14 +370,14 @@
memset(memory, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_NONE) == 0);
for (size_t i = 0; i < pagesize; i++) {
uint8_t* buf = &memory[pagesize-i];
test_func(buf, i);
}
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory);
}
@@ -379,7 +391,7 @@
memset(memory, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_NONE) == 0);
uint8_t* dst_buffer = new uint8_t[2*pagesize];
// Change the dst alignment as we change the source.
@@ -391,7 +403,7 @@
test_func(src, dst, j);
}
}
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory);
delete[] dst_buffer;
}
@@ -409,7 +421,7 @@
memset(memory1, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory1[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory1[pagesize], pagesize, PROT_NONE) == 0);
uint8_t* memory2;
ASSERT_TRUE(posix_memalign(reinterpret_cast<void**>(&memory2), pagesize,
@@ -417,7 +429,7 @@
memset(memory2, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory2[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory2[pagesize], pagesize, PROT_NONE) == 0);
for (size_t i = 0; i < pagesize; i++) {
uint8_t* buf1 = &memory1[pagesize-i];
@@ -445,8 +457,8 @@
}
}
- ASSERT_TRUE(mprotect(&memory1[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
- ASSERT_TRUE(mprotect(&memory2[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory1[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory2[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory1);
free(memory2);
}
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index cb98cae..c1681ea 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -136,6 +136,7 @@
TEST(dl, preinit_system_calls) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // hwasan not initialized in preinit_array
std::string helper = GetTestlibRoot() +
"/preinit_syscall_test_helper/preinit_syscall_test_helper";
chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607
@@ -153,6 +154,9 @@
ExecTestHelper eth;
eth.SetArgs({ helper.c_str(), nullptr });
eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
+#else
+ // Force a failure when not compiled for bionic so the test is considered a pass.
+ ASSERT_TRUE(false);
#endif
}
@@ -235,6 +239,7 @@
// whose search paths include the 'ns2/' subdir.
TEST(dl, exec_with_ld_config_file) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // libclang_rt.hwasan is not found with custom ld config
if (!is_debuggable_build()) {
// LD_CONFIG_FILE is not supported on user build
return;
@@ -257,6 +262,7 @@
// additional namespaces other than the default namespace.
TEST(dl, exec_with_ld_config_file_with_ld_preload) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // libclang_rt.hwasan is not found with custom ld config
if (!is_debuggable_build()) {
// LD_CONFIG_FILE is not supported on user build
return;
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index b33cf68..bea18e5 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -367,48 +367,6 @@
EXPECT_EQ(4, f());
}
-TEST_F(DlExtTest, LoadAtFixedAddress) {
- void* start = mmap(nullptr, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- ASSERT_TRUE(start != MAP_FAILED);
- munmap(start, kLibSize);
-
- android_dlextinfo extinfo;
- extinfo.flags = ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS;
- extinfo.reserved_addr = start;
-
- handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
- ASSERT_DL_NOTNULL(handle_);
- fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
- ASSERT_DL_NOTNULL(f);
- EXPECT_GE(reinterpret_cast<void*>(f), start);
- EXPECT_LT(reinterpret_cast<void*>(f), reinterpret_cast<char*>(start) + kLibSize);
-
- EXPECT_EQ(4, f());
- dlclose(handle_);
- handle_ = nullptr;
-
- // Check that dlclose unmapped the file
- void* addr = mmap(start, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- ASSERT_EQ(start, addr) << "dlclose did not unmap the memory";
-}
-
-TEST_F(DlExtTest, LoadAtFixedAddressTooSmall) {
- void* start = mmap(nullptr, kLibSize + PAGE_SIZE, PROT_NONE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- ASSERT_TRUE(start != MAP_FAILED);
- munmap(start, kLibSize + PAGE_SIZE);
- void* new_addr = mmap(reinterpret_cast<uint8_t*>(start) + PAGE_SIZE, kLibSize, PROT_NONE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- ASSERT_TRUE(new_addr != MAP_FAILED);
-
- android_dlextinfo extinfo;
- extinfo.flags = ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS;
- extinfo.reserved_addr = start;
-
- handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
- ASSERT_TRUE(handle_ == nullptr);
-}
-
class DlExtRelroSharingTest : public DlExtTest {
protected:
virtual void SetUp() {
diff --git a/tests/getcwd_test.cpp b/tests/getcwd_test.cpp
index f8f205e..791ffae 100644
--- a/tests/getcwd_test.cpp
+++ b/tests/getcwd_test.cpp
@@ -20,6 +20,8 @@
#include <limits.h>
#include <unistd.h>
+#include "utils.h"
+
TEST(getcwd, auto_full) {
// If we let the library do all the work, everything's fine.
errno = 0;
@@ -49,6 +51,7 @@
}
TEST(getcwd, auto_too_large) {
+ SKIP_WITH_HWASAN; // allocation size too large
// If we ask the library to allocate an unreasonably large buffer, ERANGE.
errno = 0;
char* cwd = getcwd(nullptr, static_cast<size_t>(-1));
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 5c4eb42..79c9a06 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -531,8 +531,6 @@
defaults: ["bionic_testlib_defaults"],
srcs: ["dl_df_1_global.cpp"],
ldflags: ["-Wl,-z,global"],
- // b/80109858, clang lld ignores -z,global
- use_clang_lld: false,
target: {
host: {
@@ -561,8 +559,6 @@
defaults: ["bionic_testlib_defaults"],
srcs: ["dl_df_1_global_dummy.cpp"],
ldflags: ["-Wl,-z,global"],
- // b/80109858, clang lld ignores -z,global
- use_clang_lld: false,
target: {
host: {
diff --git a/tests/libs/cfi_test_helper.cpp b/tests/libs/cfi_test_helper.cpp
index ff313a2..c1a7b6d 100644
--- a/tests/libs/cfi_test_helper.cpp
+++ b/tests/libs/cfi_test_helper.cpp
@@ -27,11 +27,13 @@
static int g_count;
// Mock a CFI-enabled library without relying on the compiler.
-extern "C" __attribute__((aligned(4096))) void __cfi_check(uint64_t /*CallSiteTypeId*/,
- void* /*TargetAddr*/, void* /*Diag*/) {
+extern "C" __attribute__((no_sanitize("hwaddress"))) __attribute__((aligned(4096)))
+void __cfi_check(uint64_t /*CallSiteTypeId*/, void* /*TargetAddr*/, void* /*Diag*/) {
++g_count;
}
+// This code runs before hwasan is initialized.
+__attribute__((no_sanitize("hwaddress")))
void preinit_ctor() {
CHECK(g_count == 0);
__cfi_slowpath(42, reinterpret_cast<void*>(&preinit_ctor));
diff --git a/tests/malloc_iterate_test.cpp b/tests/malloc_iterate_test.cpp
index 2b7b887..5e60a6d 100644
--- a/tests/malloc_iterate_test.cpp
+++ b/tests/malloc_iterate_test.cpp
@@ -26,6 +26,8 @@
#include <procinfo/process_map.h>
+#include "utils.h"
+
extern "C" void malloc_disable();
extern "C" void malloc_enable();
extern "C" int malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t base,
@@ -130,6 +132,7 @@
// Verify that small allocs can be found properly.
TEST(malloc_iterate, small_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data;
// Try to cycle through all of the different small bins.
@@ -153,6 +156,7 @@
// Verify that large allocs can be found properly.
TEST(malloc_iterate, large_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data;
// Try some larger sizes.
@@ -172,6 +176,7 @@
// non-allocated pointers.
TEST(malloc_iterate, invalid_pointers) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data = {};
// Find all of the maps that are not [anon:libc_malloc].
@@ -192,6 +197,7 @@
TEST(malloc_iterate, malloc_disable_prevents_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
pid_t pid;
if ((pid = fork()) == 0) {
malloc_disable();
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index c4f13f6..8b670f0 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -25,6 +25,7 @@
#include <tinyxml2.h>
#include "private/bionic_config.h"
+#include "utils.h"
#if defined(__BIONIC__)
#define HAVE_REALLOCARRAY 1
@@ -41,6 +42,7 @@
}
TEST(malloc, malloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, malloc(SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -59,12 +61,14 @@
}
TEST(malloc, calloc_illegal) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(-1, 100));
ASSERT_EQ(ENOMEM, errno);
}
TEST(malloc, calloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(1, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -80,6 +84,7 @@
}
TEST(malloc, memalign_multiple) {
+ SKIP_WITH_HWASAN; // hwasan requires power of 2 alignment.
// Memalign test where the alignment is any value.
for (size_t i = 0; i <= 12; i++) {
for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) {
@@ -94,10 +99,12 @@
}
TEST(malloc, memalign_overflow) {
+ SKIP_WITH_HWASAN;
ASSERT_EQ(nullptr, memalign(4096, SIZE_MAX));
}
TEST(malloc, memalign_non_power2) {
+ SKIP_WITH_HWASAN;
void* ptr;
for (size_t align = 0; align <= 256; align++) {
ptr = memalign(align, 1024);
@@ -280,6 +287,7 @@
}
TEST(malloc, realloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, realloc(nullptr, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -504,6 +512,27 @@
ASSERT_EQ(0, errno);
}
+TEST(malloc, mallopt_decay) {
+#if defined(__BIONIC__)
+ errno = 0;
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
+#else
+ GTEST_LOG_(INFO) << "This tests a bionic implementation detail.\n";
+#endif
+}
+
+TEST(malloc, mallopt_purge) {
+#if defined(__BIONIC__)
+ errno = 0;
+ ASSERT_EQ(1, mallopt(M_PURGE, 0));
+#else
+ GTEST_LOG_(INFO) << "This tests a bionic implementation detail.\n";
+#endif
+}
+
TEST(malloc, reallocarray_overflow) {
#if HAVE_REALLOCARRAY
// Values that cause overflow to a result small enough (8 on LP64) that malloc would "succeed".
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 1c3e1d1..14848ae 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -35,6 +35,8 @@
#include <limits>
#include <string>
+#include "utils.h"
+
#if defined(__BIONIC__)
#define ALIGNED_ALLOC_AVAILABLE 1
#elif defined(__GLIBC_PREREQ)
@@ -191,6 +193,7 @@
}
TEST(stdlib, posix_memalign_sweep) {
+ SKIP_WITH_HWASAN;
void* ptr;
// These should all fail.
@@ -230,11 +233,13 @@
}
TEST(stdlib, posix_memalign_overflow) {
+ SKIP_WITH_HWASAN;
void* ptr;
ASSERT_NE(0, posix_memalign(&ptr, 16, SIZE_MAX));
}
TEST(stdlib, aligned_alloc_sweep) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
// Verify powers of 2 up to 2048 allocate, and verify that all other
// alignment values between the powers of 2 fail.
@@ -259,6 +264,7 @@
}
TEST(stdlib, aligned_alloc_overflow) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
ASSERT_TRUE(aligned_alloc(16, SIZE_MAX) == nullptr);
#else
@@ -267,6 +273,7 @@
}
TEST(stdlib, aligned_alloc_size_not_multiple_of_alignment) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
for (size_t size = 1; size <= 2048; size++) {
void* ptr = aligned_alloc(2048, size);
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index e82f15d..4ec5976 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -488,23 +488,6 @@
ASSERT_EQ(EINVAL, errno);
}
-TEST(time, timer_delete_multiple) {
- timer_t timer_id;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, nullptr, &timer_id));
- ASSERT_EQ(0, timer_delete(timer_id));
- ASSERT_EQ(-1, timer_delete(timer_id));
- ASSERT_EQ(EINVAL, errno);
-
- sigevent_t se;
- memset(&se, 0, sizeof(se));
- se.sigev_notify = SIGEV_THREAD;
- se.sigev_notify_function = NoOpNotifyFunction;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, &se, &timer_id));
- ASSERT_EQ(0, timer_delete(timer_id));
- ASSERT_EQ(-1, timer_delete(timer_id));
- ASSERT_EQ(EINVAL, errno);
-}
-
TEST(time, timer_create_multiple) {
Counter counter1(Counter::CountNotifyFunction);
Counter counter2(Counter::CountNotifyFunction);
diff --git a/tests/utils.h b/tests/utils.h
index c8656dc..5fc1d93 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -58,6 +58,14 @@
return (dlopen("libc.so", 0) != nullptr);
}
+extern "C" void __hwasan_init() __attribute__((weak));
+
+static inline bool running_with_hwasan() {
+ return &__hwasan_init != 0;
+}
+
+#define SKIP_WITH_HWASAN if (running_with_hwasan()) { return; }
+
#if defined(__linux__)
#include <sys/sysmacros.h>
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index 7c4aa23..8ba3d42 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -29,7 +29,6 @@
#include <clang/AST/ASTConsumer.h>
#include <clang/Basic/Diagnostic.h>
#include <clang/Basic/TargetInfo.h>
-#include <clang/Basic/VirtualFileSystem.h>
#include <clang/Driver/Compilation.h>
#include <clang/Driver/Driver.h>
#include <clang/Frontend/CompilerInstance.h>
@@ -42,6 +41,7 @@
#include <llvm/ADT/IntrusiveRefCntPtr.h>
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringRef.h>
+#include <llvm/Support/VirtualFileSystem.h>
#include "Arch.h"
#include "DeclarationDatabase.h"
@@ -93,7 +93,7 @@
// Run it once to generate flags for each target, and memoize the results.
static std::unordered_map<CompilationType, std::vector<std::string>> cc1_flags;
static const char* filename_placeholder = "__VERSIONER_PLACEHOLDER__";
-static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
CompilationType type,
const std::vector<std::string>& include_dirs) {
std::vector<std::string> cmd = { "versioner" };
@@ -207,7 +207,7 @@
return result;
}
-void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
const std::set<CompilationType>& types,
const std::unordered_map<Arch, CompilationRequirements>& reqs) {
if (!cc1_flags.empty()) {
@@ -242,7 +242,7 @@
}
}
-void compileHeader(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void compileHeader(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
HeaderDatabase* header_database, CompilationType type,
const std::string& filename) {
auto diags = constructDiags();
diff --git a/tools/versioner/src/Driver.h b/tools/versioner/src/Driver.h
index 48683e4..99e57ae 100644
--- a/tools/versioner/src/Driver.h
+++ b/tools/versioner/src/Driver.h
@@ -31,10 +31,10 @@
std::vector<std::string> dependencies;
};
-void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
const std::set<CompilationType>& types,
const std::unordered_map<Arch, CompilationRequirements>& reqs);
-void compileHeader(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void compileHeader(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
HeaderDatabase* header_database, CompilationType type,
const std::string& filename);
diff --git a/tools/versioner/src/VFS.cpp b/tools/versioner/src/VFS.cpp
index 8f9de88..d797f82 100644
--- a/tools/versioner/src/VFS.cpp
+++ b/tools/versioner/src/VFS.cpp
@@ -25,14 +25,14 @@
#include <string>
#include <android-base/unique_fd.h>
-#include <clang/Basic/VirtualFileSystem.h>
#include <llvm/ADT/IntrusiveRefCntPtr.h>
#include <llvm/Support/MemoryBuffer.h>
+#include <llvm/Support/VirtualFileSystem.h>
#include "Utils.h"
using android::base::unique_fd;
-using namespace clang::vfs;
+using namespace llvm::vfs;
static void addDirectoryToVFS(InMemoryFileSystem* vfs, const std::string& path) {
char* paths[] = { const_cast<char*>(path.c_str()), nullptr };
diff --git a/tools/versioner/src/VFS.h b/tools/versioner/src/VFS.h
index e2ab002..e4aac75 100644
--- a/tools/versioner/src/VFS.h
+++ b/tools/versioner/src/VFS.h
@@ -20,8 +20,8 @@
#include <string>
#include <llvm/ADT/IntrusiveRefCntPtr.h>
-#include <clang/Basic/VirtualFileSystem.h>
+#include <llvm/Support/VirtualFileSystem.h>
-llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> createCommonVFS(const std::string& header_dir,
- const std::string& dependency_dir,
- bool add_versioning_header);
+llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> createCommonVFS(const std::string& header_dir,
+ const std::string& dependency_dir,
+ bool add_versioning_header);