Merge "bionic: split out getpwnam and friends"
diff --git a/libc/dns/resolv/res_stats.c b/libc/dns/resolv/res_stats.c
index b6f5ecb..5cc592e 100644
--- a/libc/dns/resolv/res_stats.c
+++ b/libc/dns/resolv/res_stats.c
@@ -22,7 +22,7 @@
#include "private/libc_logging.h"
#include "isc/eventlib.h"
-#define DBG 1
+#define DBG 0
/* Calculate the round-trip-time from start time t0 and end time t1. */
int
diff --git a/linker/linker_sleb128.h b/linker/linker_sleb128.h
index a34916f..c4df259 100644
--- a/linker/linker_sleb128.h
+++ b/linker/linker_sleb128.h
@@ -19,6 +19,8 @@
#include <stdint.h>
+#include "linker_debug.h"
+
// Helper classes for decoding LEB128, used in packed relocation data.
// http://en.wikipedia.org/wiki/LEB128
diff --git a/linker/tests/Android.mk b/linker/tests/Android.mk
index e9f43e9..48c6374 100644
--- a/linker/tests/Android.mk
+++ b/linker/tests/Android.mk
@@ -27,17 +27,17 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../libc/
LOCAL_SRC_FILES := \
+ linker_block_allocator_test.cpp \
linker_globals.cpp \
linked_list_test.cpp \
- linker_block_allocator_test.cpp \
- ../linker_block_allocator.cpp \
linker_memory_allocator_test.cpp \
+ linker_sleb128_test.cpp \
linker_utils_test.cpp \
+ ../linker_allocator.cpp \
+ ../linker_block_allocator.cpp \
../linker_utils.cpp
# for __libc_fatal
LOCAL_SRC_FILES += ../../libc/bionic/libc_logging.cpp
-LOCAL_STATIC_LIBRARIES := liblinker_malloc
-
include $(BUILD_NATIVE_TEST)
diff --git a/linker/tests/linker_sleb128_test.cpp b/linker/tests/linker_sleb128_test.cpp
new file mode 100644
index 0000000..4e29bca
--- /dev/null
+++ b/linker/tests/linker_sleb128_test.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2016 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 <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include <gtest/gtest.h>
+
+#include "../linker_sleb128.h"
+
+TEST(linker_sleb128, smoke) {
+ std::vector<uint8_t> encoding;
+ // 624485
+ encoding.push_back(0xe5);
+ encoding.push_back(0x8e);
+ encoding.push_back(0x26);
+ // 0
+ encoding.push_back(0x00);
+ // 1
+ encoding.push_back(0x01);
+ // 63
+ encoding.push_back(0x3f);
+ // 64
+ encoding.push_back(0xc0);
+ encoding.push_back(0x00);
+ // -1
+ encoding.push_back(0x7f);
+ // -624485
+ encoding.push_back(0x9b);
+ encoding.push_back(0xf1);
+ encoding.push_back(0x59);
+ // 2147483647
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0x07);
+ // -2147483648
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x78);
+#if defined(__LP64__)
+ // 9223372036854775807
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0xff);
+ encoding.push_back(0x00);
+ // -9223372036854775808
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x80);
+ encoding.push_back(0x7f);
+#endif
+ sleb128_decoder decoder(&encoding[0], encoding.size());
+
+ EXPECT_EQ(624485U, decoder.pop_front());
+
+ EXPECT_EQ(0U, decoder.pop_front());
+ EXPECT_EQ(1U, decoder.pop_front());
+ EXPECT_EQ(63U, decoder.pop_front());
+ EXPECT_EQ(64U, decoder.pop_front());
+ EXPECT_EQ(static_cast<size_t>(-1), decoder.pop_front());
+ EXPECT_EQ(static_cast<size_t>(-624485), decoder.pop_front());
+ EXPECT_EQ(2147483647U, decoder.pop_front());
+ EXPECT_EQ(static_cast<size_t>(-2147483648), decoder.pop_front());
+#if defined(__LP64__)
+ EXPECT_EQ(9223372036854775807ULL, decoder.pop_front());
+ EXPECT_EQ(static_cast<uint64_t>(-9223372036854775807LL - 1), decoder.pop_front());
+#endif
+}
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 1123163..19f9978 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -211,6 +211,8 @@
dlclose(handle);
}
+// mips doesn't support ifuncs
+#if !defined(__mips__)
TEST(dlfcn, ifunc) {
typedef const char* (*fn_ptr)();
@@ -254,6 +256,7 @@
ASSERT_STREQ("true", is_ctor_called());
dlclose(handle);
}
+#endif
TEST(dlfcn, dlopen_check_relocation_dt_needed_order) {
// This is the structure of the test library and
diff --git a/tests/libs/Android.mk b/tests/libs/Android.mk
index a903732..82bfc05 100644
--- a/tests/libs/Android.mk
+++ b/tests/libs/Android.mk
@@ -348,12 +348,19 @@
# TODO(dimitry): clang does not support ifunc attribute
libtest_ifunc_clang_host := false
-libtest_ifunc_clang_target := false
module := libtest_ifunc
build_target := SHARED_LIBRARY
-include $(LOCAL_PATH)/Android.build.testlib.mk
+build_type := host
+include $(TEST_PATH)/Android.build.mk
+
+ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm arm64 x86 x86_64))
+ build_type := target
+ libtest_ifunc_clang_target := false
+ include $(TEST_PATH)/Android.build.mk
+endif
+
# -----------------------------------------------------------------------------
# Library used by atexit tests