Created
May 25, 2017 08:55
-
-
Save neochapay/496c9b42ed0e5aa14195c2bbe02545f3 to your computer and use it in GitHub Desktop.
Bionic hybris path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libc/Android.mk b/libc/Android.mk | |
index 3005092..db1c3e6 100644 | |
--- a/libc/Android.mk | |
+++ b/libc/Android.mk | |
@@ -65,6 +65,10 @@ libc_common_src_files := \ | |
stdio/snprintf.c\ | |
stdio/sprintf.c \ | |
+ifeq ($(TARGET_NEEDS_BIONIC_MD5),true) | |
+libc_common_src_files += bionic/md5.c | |
+endif | |
+ | |
# Fortify implementations of libc functions. | |
libc_common_src_files += \ | |
bionic/__FD_chk.cpp \ | |
@@ -184,7 +188,6 @@ libc_bionic_src_files := \ | |
bionic/sched_getcpu.cpp \ | |
bionic/send.cpp \ | |
bionic/setegid.cpp \ | |
- bionic/__set_errno.cpp \ | |
bionic/seteuid.cpp \ | |
bionic/setpgrp.cpp \ | |
bionic/sigaction.cpp \ | |
@@ -535,6 +538,10 @@ ifneq ($(BOARD_MALLOC_ALIGNMENT),) | |
libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT) | |
endif | |
+ifeq ($(BOARD_USES_LEGACY_MMAP),true) | |
+ libc_common_cflags += -DLEGACY_MMAP | |
+endif | |
+ | |
# Define ANDROID_SMP appropriately. | |
ifeq ($(TARGET_CPU_SMP),true) | |
libc_common_cflags += -DANDROID_SMP=1 | |
@@ -813,11 +820,6 @@ LOCAL_SRC_FILES := $(libc_bionic_src_files) | |
LOCAL_CFLAGS := $(libc_common_cflags) \ | |
-Wframe-larger-than=2048 \ | |
-ifeq ($(TARGET_ARCH),x86_64) | |
- # Clang assembler has problem with ssse3-strcmp-slm.S, http://b/17302991 | |
- LOCAL_CLANG_ASFLAGS += -no-integrated-as | |
-endif | |
- | |
LOCAL_CONLYFLAGS := $(libc_common_conlyflags) | |
LOCAL_CPPFLAGS := $(libc_common_cppflags) | |
LOCAL_C_INCLUDES := $(libc_common_c_includes) | |
@@ -948,6 +950,7 @@ include $(CLEAR_VARS) | |
LOCAL_SRC_FILES := \ | |
$(libc_arch_static_src_files) \ | |
$(libc_static_common_src_files) \ | |
+ bionic/__set_errno.cpp \ | |
bionic/libc_init_static.cpp | |
LOCAL_C_INCLUDES := $(libc_common_c_includes) | |
@@ -994,6 +997,7 @@ include $(CLEAR_VARS) | |
LOCAL_SRC_FILES := \ | |
$(libc_arch_static_src_files) \ | |
$(libc_static_common_src_files) \ | |
+ bionic/__set_errno.cpp \ | |
bionic/malloc_debug_common.cpp \ | |
bionic/libc_init_static.cpp \ | |
@@ -1047,7 +1051,7 @@ LOCAL_STRIP_MODULE := keep_symbols | |
# create a "cloaked" dependency on libgcc.a in libc though the libraries, which is not what | |
# you wanted! | |
-LOCAL_SHARED_LIBRARIES := libdl | |
+LOCAL_SHARED_LIBRARIES := libdl libdsyscalls | |
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common | |
LOCAL_SYSTEM_SHARED_LIBRARIES := | |
@@ -1069,9 +1073,48 @@ LOCAL_SRC_FILES_arm += \ | |
arch-arm/bionic/atexit_legacy.c \ | |
arch-common/bionic/crtend_so.S | |
+# Allow devices to provide additional symbols | |
+LOCAL_WHOLE_STATIC_LIBRARIES += $(BOARD_PROVIDES_ADDITIONAL_BIONIC_STATIC_LIBS) | |
+ | |
include $(BUILD_SHARED_LIBRARY) | |
+# ======================================================== | |
+# libdsyscalls.so | |
+# ======================================================== | |
+include $(CLEAR_VARS) | |
+ | |
+# NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from | |
+# libgcc.a are made static to libdyscalls.so. This in turn ensures that libraries that | |
+# a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so | |
+# to provide those symbols, but will instead pull them from libgcc.a. Specifically, | |
+# we use this property to make sure libc.so has its own copy of the code from | |
+# libgcc.a it uses. | |
+# | |
+# DO NOT REMOVE --exclude-libs! | |
+ | |
+LOCAL_LDFLAGS := -Wl,--exclude-libs=libgcc.a | |
+ | |
+# for x86, exclude libgcc_eh.a for the same reasons as above | |
+LOCAL_LDFLAGS_x86 := -Wl,--exclude-libs=libgcc_eh.a | |
+LOCAL_LDFLAGS_x86_64 := $(LOCAL_LDFLAGS_x86) | |
+ | |
+LOCAL_SRC_FILES:= hybris/libdsyscalls.c | |
+LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror | |
+ | |
+LOCAL_MODULE := libdsyscalls | |
+LOCAL_ADDITIONAL_DEPENDENCIES := | |
+ | |
+# NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a | |
+# few symbols from libc. Using --no-undefined here results in having to link | |
+# against libc creating a circular dependency which is removed and we end up | |
+# with missing symbols. Since this library is just a bunch of stubs, we set | |
+# LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags. | |
+LOCAL_ALLOW_UNDEFINED_SYMBOLS := true | |
+LOCAL_SYSTEM_SHARED_LIBRARIES := | |
+ | |
+include $(BUILD_SHARED_LIBRARY) | |
+ | |
# For all builds, except for the -user build we will enable memory | |
# allocation checking (including memory leaks, buffer overwrites, etc.) | |
# Note that all these checks are also controlled by env. settings | |
diff --git a/libc/bionic/__set_errno.cpp b/libc/bionic/__set_errno.cpp | |
index 30df350..5311bf8 100644 | |
--- a/libc/bionic/__set_errno.cpp | |
+++ b/libc/bionic/__set_errno.cpp | |
@@ -40,7 +40,7 @@ | |
// We need the extra level of indirection so that the .hidden directives | |
// in the system call stubs don't cause __set_errno to be hidden, breaking | |
// old NDK apps. | |
- | |
+#ifdef LIBC_STATIC | |
// This one is for internal use only and used by both LP32 and LP64 assembler. | |
extern "C" __LIBC_HIDDEN__ long __set_errno_internal(int n) { | |
errno = n; | |
@@ -53,3 +53,4 @@ extern "C" long __set_errno(int n) { | |
return __set_errno_internal(n); | |
} | |
#endif | |
+#endif | |
diff --git a/libc/bionic/libc_logging.cpp b/libc/bionic/libc_logging.cpp | |
index 5655526..ffe91f6 100644 | |
--- a/libc/bionic/libc_logging.cpp | |
+++ b/libc/bionic/libc_logging.cpp | |
@@ -517,7 +517,7 @@ static int __libc_write_log(int priority, const char* tag, const char* msg) { | |
vec[5].iov_base = const_cast<char*>(msg); | |
vec[5].iov_len = strlen(msg) + 1; | |
#else | |
- int main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY)); | |
+ int main_log_fd = TEMP_FAILURE_RETRY(open("/dev/alog/main", O_CLOEXEC | O_WRONLY)); | |
if (main_log_fd == -1) { | |
if (errno == ENOTDIR) { | |
// /dev/log isn't a directory? Maybe we're running on the host? Try stderr instead. | |
@@ -589,7 +589,7 @@ static int __libc_android_log_event(int32_t tag, char type, const void* payload, | |
vec[2].iov_base = const_cast<void*>(payload); | |
vec[2].iov_len = len; | |
- int event_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/events", O_CLOEXEC | O_WRONLY)); | |
+ int event_log_fd = TEMP_FAILURE_RETRY(open("/dev/alog/events", O_CLOEXEC | O_WRONLY)); | |
#endif | |
if (event_log_fd == -1) { | |
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp | |
index 0b6a142..fb3ac12 100644 | |
--- a/libc/bionic/malloc_debug_common.cpp | |
+++ b/libc/bionic/malloc_debug_common.cpp | |
@@ -382,6 +382,9 @@ static void malloc_init_impl() { | |
case 10: | |
so_name = "libc_malloc_debug_leak.so"; | |
break; | |
+ case 15: | |
+ so_name = "libefence.so"; | |
+ break; | |
case 20: | |
// Quick check: debug level 20 can only be handled in emulator. | |
if (!qemu_running) { | |
@@ -453,6 +456,9 @@ static void malloc_init_impl() { | |
case 10: | |
InitMalloc(malloc_impl_handle, &malloc_dispatch_table, "chk"); | |
break; | |
+ case 15: | |
+ InitMalloc(malloc_impl_handle, &malloc_dispatch_table, "efence"); | |
+ break; | |
case 20: | |
InitMalloc(malloc_impl_handle, &malloc_dispatch_table, "qemu_instrumented"); | |
break; | |
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp | |
index 0e16bf3..699bf5a 100644 | |
--- a/libc/bionic/system_properties.cpp | |
+++ b/libc/bionic/system_properties.cpp | |
@@ -1,4 +1,3 @@ | |
-/* | |
* Copyright (C) 2008 The Android Open Source Project | |
* All rights reserved. | |
* | |
@@ -622,6 +621,12 @@ int __system_property_get(const char *name, char *value) | |
{ | |
const prop_info *pi = __system_property_find(name); | |
+ /* In case we're called from Ubuntu */ | |
+ if (__system_property_area__ == NULL) { | |
+ value[0] = 0; | |
+ return 0; | |
+ } | |
+ | |
if (pi != 0) { | |
return __system_property_read(pi, 0, value); | |
} else { | |
diff --git a/libc/hybris/libdsyscalls.c b/libc/hybris/libdsyscalls.c | |
new file mode 100644 | |
index 0000000..d2e248b | |
--- /dev/null | |
+++ b/libc/hybris/libdsyscalls.c | |
@@ -0,0 +1,39 @@ | |
+/* | |
+ * Copyright (C) 2007 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 <errno.h> | |
+#include <sys/cdefs.h> | |
+ | |
+/* Define __set_errno here so it can be hijacked by libhybris | |
+ * at runtime (called from __set_syscall_errno) | |
+ */ | |
+int __set_errno(int n) | |
+{ | |
+ errno = n; | |
+ return -1; | |
+} | |
+ | |
+long __set_errno_internal(int n) { | |
+ errno = n; | |
+ return -1; | |
+} | |
+ | |
+static __thread void *tls_hooks[16]; | |
+ | |
+void *__get_tls_hooks() | |
+{ | |
+ return tls_hooks; | |
+} | |
diff --git a/libc/include/netdb.h b/libc/include/netdb.h | |
index 527d5c1..9216efe 100644 | |
--- a/libc/include/netdb.h | |
+++ b/libc/include/netdb.h | |
@@ -242,6 +242,8 @@ void setnetent(int); | |
void setprotoent(int); | |
int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); | |
int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); | |
+int android_getnameinfoforiface(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int, const char *, int); | |
+struct hostent *android_gethostbyaddrforiface_proxy(const void *, socklen_t, int, const char *, int); | |
void freeaddrinfo(struct addrinfo *); | |
const char *gai_strerror(int); | |
void setnetgrent(const char *); | |
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h | |
index 0349e4c..0a859c3 100644 | |
--- a/libc/include/sys/_system_properties.h | |
+++ b/libc/include/sys/_system_properties.h | |
@@ -58,7 +58,8 @@ struct prop_msg | |
}; | |
#define PROP_MSG_SETPROP 1 | |
- | |
+#define PROP_MSG_GETPROP 2 | |
+#define PROP_MSG_LISTPROP 3 | |
/* | |
** Rules: | |
** | |
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h | |
index 56a61be..8960c49 100644 | |
--- a/libc/private/bionic_tls.h | |
+++ b/libc/private/bionic_tls.h | |
@@ -51,12 +51,12 @@ __BEGIN_DECLS | |
enum { | |
TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86. | |
TLS_SLOT_THREAD_ID, | |
- TLS_SLOT_ERRNO, | |
+ TLS_SLOT_ERRNO = 5, | |
// These two aren't used by bionic itself, but allow the graphics code to | |
// access TLS directly rather than using the pthread API. | |
- TLS_SLOT_OPENGL_API = 3, | |
- TLS_SLOT_OPENGL = 4, | |
+ TLS_SLOT_OPENGL_API = 6, | |
+ TLS_SLOT_OPENGL = 7, | |
// This slot is only used to pass information from the dynamic linker to | |
// libc.so when the C library is loaded in to memory. The C runtime init | |
@@ -64,7 +64,7 @@ enum { | |
// we reuse an existing location that isn't needed during libc startup. | |
TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API, | |
- TLS_SLOT_STACK_GUARD = 5, // GCC requires this specific slot for x86. | |
+ TLS_SLOT_STACK_GUARD = 8, // GCC requires this specific slot for x86. | |
TLS_SLOT_DLERROR, | |
TLS_SLOT_FIRST_USER_SLOT // Must come last! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment