Merge "Remove bionic-unit-tests-gcc"
diff --git a/libc/Android.bp b/libc/Android.bp
index 4df94a0..ec00f28 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1869,6 +1869,21 @@
],
}
+cc_object {
+ name: "kuser_helper_on",
+ local_include_dirs: ["include"],
+ arch: {
+ arm: {
+ srcs: ["arch-arm/bionic/kuser_helper_on.S"],
+ },
+ },
+
+ defaults: [
+ "crt_defaults",
+ "crt_so_defaults",
+ ],
+}
+
// Android.mk:ignore
cc_object {
name: "crtbegin_so1",
@@ -1893,6 +1908,11 @@
"crtbegin_so1",
"crtbrand",
],
+ arch: {
+ arm: {
+ objs: ["kuser_helper_on"],
+ },
+ },
}
// Android.mk:ignore
@@ -1951,6 +1971,11 @@
"crtbegin_static1",
"crtbrand",
],
+ arch: {
+ arm: {
+ objs: ["kuser_helper_on"],
+ },
+ },
defaults: ["crt_defaults"],
}
@@ -1997,6 +2022,11 @@
"crtbegin_dynamic1",
"crtbrand",
],
+ arch: {
+ arm: {
+ objs: ["kuser_helper_on"],
+ },
+ },
defaults: ["crt_defaults"],
}
diff --git a/libc/NOTICE b/libc/NOTICE
index fd6cee6..550b9d6 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -932,6 +932,34 @@
-------------------------------------------------------------------
+Copyright (C) 2017 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.
+
+-------------------------------------------------------------------
+
Copyright (c) 1980, 1983, 1988, 1993
The Regents of the University of California. All rights reserved.
diff --git a/libc/arch-arm/bionic/kuser_helper_on.S b/libc/arch-arm/bionic/kuser_helper_on.S
new file mode 100644
index 0000000..e59d0d5
--- /dev/null
+++ b/libc/arch-arm/bionic/kuser_helper_on.S
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+ .section .note.android.kuser_helper_off,"a",%note
+ .align 2
+ .type abitag, %object
+abitag:
+ .long 2f-1f /* int32_t namesz */
+ .long 3f-2f /* int32_t descsz */
+ .long 3 /* int32_t type */
+1: .ascii "Android\0" /* char name[] */
+2: .long 1 /* int32_t on */
+3:
+ .size abitag, .-abitag
diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h
index 7182ca6..37c1891 100644
--- a/libc/dns/include/resolv_netid.h
+++ b/libc/dns/include/resolv_netid.h
@@ -71,7 +71,7 @@
unsigned dns_netid;
unsigned dns_mark;
uid_t uid;
-} __attribute__((packed));
+};
#define NET_CONTEXT_INVALID_UID ((uid_t)-1)
diff --git a/libc/dns/include/resolv_params.h b/libc/dns/include/resolv_params.h
index 5ee265f..49ae691 100644
--- a/libc/dns/include/resolv_params.h
+++ b/libc/dns/include/resolv_params.h
@@ -41,6 +41,6 @@
uint8_t success_threshold; // 0: disable, value / 100 otherwise
uint8_t min_samples; // min # samples needed for statistics to be considered meaningful
uint8_t max_samples; // max # samples taken into account for statistics
-} __attribute__((__packed__));
+};
#endif // _RESOLV_PARAMS_H
diff --git a/libc/seccomp/arm64_policy.c b/libc/seccomp/arm64_policy.c
index d5a87d6..6a8bda0 100644
--- a/libc/seccomp/arm64_policy.c
+++ b/libc/seccomp/arm64_policy.c
@@ -41,7 +41,7 @@
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 268, 1, 0),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 267, 1, 2), //clock_adjtime
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 272, 0, 1), //setns|sendmmsg|process_vm_readv|process_vm_writev
-BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
+BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRAP),
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
};
diff --git a/libc/seccomp/arm_policy.c b/libc/seccomp/arm_policy.c
index 44e734e..de03f45 100644
--- a/libc/seccomp/arm_policy.c
+++ b/libc/seccomp/arm_policy.c
@@ -139,7 +139,7 @@
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 983045, 1, 0),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 983043, 1, 2), //__ARM_NR_cacheflush
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 983046, 0, 1), //__ARM_NR_set_tls
-BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
+BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRAP),
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
};
diff --git a/libc/tools/genseccomp.py b/libc/tools/genseccomp.py
index b82bb12..bd003a3 100755
--- a/libc/tools/genseccomp.py
+++ b/libc/tools/genseccomp.py
@@ -126,7 +126,7 @@
", 0, " + str(len(bpf)) + "),")
# Add the error and allow calls at the end
- bpf.append("BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),")
+ bpf.append("BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRAP),")
bpf.append("BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),")
# And output policy
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 2e4d635..a56e3a7 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -921,7 +921,25 @@
#else
#define PATH_TO_SYSTEM_LIB "/system/lib/"
#endif
+#if defined (__aarch64__)
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/arm64/"
+#elif defined (__arm__)
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/arm/"
+#elif defined (__i386__)
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/x86/"
+#elif defined (__x86_64__)
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/x86_64/"
+#elif defined (__mips__)
+#if defined(__LP64__)
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/mips64/"
+#else
+#define ALTERNATE_PATH_TO_SYSTEM_LIB "/system/lib/mips/"
+#endif
+#else
+#error "Unknown architecture"
+#endif
#define PATH_TO_LIBC PATH_TO_SYSTEM_LIB "libc.so"
+#define ALTERNATE_PATH_TO_LIBC ALTERNATE_PATH_TO_SYSTEM_LIB "libc.so"
TEST(dlfcn, dladdr_libc) {
#if defined(__BIONIC__)
@@ -929,9 +947,18 @@
void* addr = reinterpret_cast<void*>(puts); // well-known libc function
ASSERT_TRUE(dladdr(addr, &info) != 0);
- // /system/lib is symlink when this test is executed on host.
char libc_realpath[PATH_MAX];
- ASSERT_TRUE(realpath(PATH_TO_LIBC, libc_realpath) == libc_realpath);
+
+ // Check if libc is in canonical path or in alternate path.
+ if (strncmp(ALTERNATE_PATH_TO_SYSTEM_LIB,
+ info.dli_fname,
+ sizeof(ALTERNATE_PATH_TO_SYSTEM_LIB) - 1) == 0) {
+ // Platform with emulated architecture. Symlink on ARC++.
+ ASSERT_TRUE(realpath(ALTERNATE_PATH_TO_LIBC, libc_realpath) == libc_realpath);
+ } else {
+ // /system/lib is symlink when this test is executed on host.
+ ASSERT_TRUE(realpath(PATH_TO_LIBC, libc_realpath) == libc_realpath);
+ }
ASSERT_STREQ(libc_realpath, info.dli_fname);
// TODO: add check for dfi_fbase
@@ -1248,8 +1275,14 @@
}
void validate_compatibility_of_native_library(const char* soname) {
- std::string path = std::string(PATH_TO_SYSTEM_LIB) + soname;
+ // On the systems with emulation system libraries would be of different
+ // architecture. Try to use alternate paths first.
+ std::string path = std::string(ALTERNATE_PATH_TO_SYSTEM_LIB) + soname;
auto binary_or_error = llvm::object::createBinary(path);
+ if (!binary_or_error) {
+ path = std::string(PATH_TO_SYSTEM_LIB) + soname;
+ binary_or_error = llvm::object::createBinary(path);
+ }
ASSERT_FALSE(!binary_or_error);
llvm::object::Binary* binary = binary_or_error.get().getBinary();