Merge "Add "__noreturn" to assert and assert2"
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index f20a005..b790e2b 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -43,20 +43,19 @@
 extern "C" pid_t __bionic_clone(uint32_t flags, void* child_stack, int* parent_tid, void* tls, int* child_tid, int (*fn)(void*), void* arg);
 extern "C" int __set_tls(void*);
 
+// Used by gdb to track thread creation. See libthread_db.
 #ifdef __i386__
-#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
+extern "C" __attribute__((noinline)) __attribute__((fastcall)) void _thread_created_hook(pid_t) {}
 #else
-#define ATTRIBUTES __attribute__((noinline))
+extern "C" __attribute__((noinline)) void _thread_created_hook(pid_t) {}
 #endif
 
-extern "C" void ATTRIBUTES _thread_created_hook(pid_t thread_id);
-
 static pthread_mutex_t gPthreadStackCreationLock = PTHREAD_MUTEX_INITIALIZER;
 
 static pthread_mutex_t gDebuggerNotificationLock = PTHREAD_MUTEX_INITIALIZER;
 
 // This code is used both by each new pthread and the code that initializes the main thread.
-void  __init_tls(pthread_internal_t* thread) {
+void __init_tls(pthread_internal_t* thread) {
   // Zero-initialize all the slots after TLS_SLOT_SELF and TLS_SLOT_THREAD_ID.
   for (size_t i = TLS_SLOT_ERRNO; i < BIONIC_TLS_SLOTS; ++i) {
     thread->tls[i] = NULL;
diff --git a/libc/bionic/ptrace.cpp b/libc/bionic/ptrace.cpp
index c0fd5de..5715b09 100644
--- a/libc/bionic/ptrace.cpp
+++ b/libc/bionic/ptrace.cpp
@@ -51,17 +51,3 @@
       return __ptrace(request, pid, addr, data);
   }
 }
-
-/*
- * Hook for gdb to get notified when a thread is created
- */
-#ifdef __i386__
-#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
-#else
-#define ATTRIBUTES __attribute__((noinline))
-#endif
-
-extern "C" void _thread_created_hook(pid_t) ATTRIBUTES;
-
-void _thread_created_hook(pid_t) {
-}
diff --git a/libc/private/bionic_atomic_aarch64.h b/libc/private/bionic_atomic_aarch64.h
index 568382e..c3a34e1 100644
--- a/libc/private/bionic_atomic_aarch64.h
+++ b/libc/private/bionic_atomic_aarch64.h
@@ -29,15 +29,15 @@
   int32_t tmp, oldval;
   __asm__ __volatile__ (
       "// atomic_cmpxchg\n"
-      "1:  ldaxr %w1, [%3]\n"
+      "1:  ldxr %w1, [%3]\n"
       "    cmp %w1, %w4\n"
       "    b.ne 2f\n"
-      "    stlxr %w0, %w5, [%3]\n"
+      "    stxr %w0, %w5, [%3]\n"
       "    cbnz  %w0, 1b\n"
       "2:"
       : "=&r" (tmp), "=&r" (oldval), "+o"(*ptr)
       : "r" (ptr), "Ir" (old_value), "r" (new_value)
-      : "cc");
+      : "cc", "memory");
   return oldval != old_value;
 }
 
@@ -51,7 +51,7 @@
       "    cbnz %w1, 1b\n"
       : "=&r" (prev), "=&r" (status), "+o" (*ptr)
       : "r" (ptr), "r" (new_value)
-      : "cc");
+      : "cc", "memory");
   return prev;
 }
 
@@ -65,7 +65,7 @@
       "    cbnz %w2, 1b"
       : "=&r" (prev), "=&r" (tmp), "=&r" (status), "+m"(*ptr)
       : "r" (ptr)
-      : "cc");
+      : "cc", "memory");
   return prev;
 }
 
diff --git a/libdl/Android.mk b/libdl/Android.mk
index 9d1e1e0..49cfb0c 100644
--- a/libdl/Android.mk
+++ b/libdl/Android.mk
@@ -23,8 +23,9 @@
 endif
 
 LOCAL_SRC_FILES:= libdl.c
+LOCAL_CFLAGS := -Wall -Wextra -Werror
 
-LOCAL_MODULE:= libdl
+LOCAL_MODULE := libdl
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 # NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a
@@ -36,23 +37,3 @@
 LOCAL_SYSTEM_SHARED_LIBRARIES :=
 
 include $(BUILD_SHARED_LIBRARY)
-
-BUILD_DLTEST:=0
-ifeq ($(BUILD_DLTEST),1)
-
-#
-# dltest
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= dltest.c
-
-LOCAL_MODULE:= dltest
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_SHARED_LIBRARIES := libdl
-
-include $(BUILD_EXECUTABLE)
-
-endif
diff --git a/libdl/NOTICE b/libdl/NOTICE
index 23d709f..77b5743 100644
--- a/libdl/NOTICE
+++ b/libdl/NOTICE
@@ -14,31 +14,3 @@
 
 -------------------------------------------------------------------
 
-Copyright (C) 2008 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.
-
--------------------------------------------------------------------
-
diff --git a/libdl/dltest.c b/libdl/dltest.c
deleted file mode 100644
index 14cd854..0000000
--- a/libdl/dltest.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <dlfcn.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] = {
-    {"library", required_argument, 0, 'l'},
-    {"symbol",  required_argument, 0, 's'},
-    {"help",    no_argument,       0, 'h'},
-    {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static const char *descriptions[] = {
-    "specify a library path to look up symbol",
-    "specify symbol to look up",
-    "print this help screen",
-};
-
-void print_help(const char *name) {
-    fprintf(stdout, 
-            "invokation:\n"
-            "\t%s [-l <libname>] -s <symbol name>\n"
-            "\t%s -h\n\n", name, name);
-    fprintf(stdout, "options:\n");
-    struct option *opt = long_options;
-    const char **desc = descriptions;
-    while (opt->name) {
-        fprintf(stdout, "\t-%c/--%s%s: %s\n",
-                opt->val,
-                opt->name,
-                (opt->has_arg ? " (argument)" : ""),
-                *desc);
-        opt++;
-        desc++;
-    }
-}
-
-int get_options(int argc, char **argv, char **lib, char **sym) 
-{
-    int c;
-
-    *lib = 0;
-    *sym = 0;
-
-    while (1) {
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, 
-                         "l:s:h",
-                         long_options, 
-                         &option_index);
-        /* Detect the end of the options. */
-        if (c == -1) break;
-
-        switch (c) {
-		case 'l':
-            *lib = strdup(optarg);
-			break;
-        case 's': 
-            *sym = strdup(optarg);
-            break;
-        case 'h': print_help(argv[0]); exit(EXIT_FAILURE); break;
-        case '?':
-            /* getopt_long already printed an error message. */
-            break;
-        default:
-            fprintf(stderr, "Unknown option");
-            exit(EXIT_FAILURE);
-        }
-    }
-
-    return optind;
-}
-
-int main(int argc, char **argv)
-{
-    char *libname, *symname, *prog = *argv;
-
-    get_options(argc, argv, &libname, &symname);
-
-    if (symname == NULL) {
-        fprintf(stderr, "You must specify a symbol!\n");
-        print_help(prog);
-        exit(EXIT_FAILURE);
-    }
-
-    {
-        const char *dlerr;
-        void *handle, *symbol;
-
-        printf("opening library [%s]\n", libname);
-        dlerr = dlerror();
-        handle = libname ? dlopen(libname, RTLD_NOW) : RTLD_DEFAULT;
-        dlerr = dlerror();
-        if (dlerr != NULL) fprintf(stderr, "dlopen() error: %s\n", dlerr);
-
-        printf("opening symbol [%s]\n", symname);
-        symbol = dlsym(handle, symname);
-        dlerr = dlerror();
-        if (dlerr != NULL) fprintf(stderr, "dlsym() error: %s\n", dlerr);
-
-        printf("closing library [%s]\n", libname);
-        dlclose(handle);
-        dlerr = dlerror();
-        if (dlerr != NULL) fprintf(stderr, "dlclose() error: %s\n", dlerr);
-        else printf("successfully opened symbol\n");
-    }
-
-    if (libname != NULL) free(libname);
-    if (symname != NULL) free(symname);
-    return 0;
-}
diff --git a/libdl/libdl.c b/libdl/libdl.c
index 548364c..310db54 100644
--- a/libdl/libdl.c
+++ b/libdl/libdl.c
@@ -15,23 +15,23 @@
  */
 
 #include <dlfcn.h>
-/* These are stubs for functions that are actually defined
- * in the dynamic linker (dlfcn.c), and hijacked at runtime.
- */
-void *dlopen(const char *filename, int flag) { return 0; }
-const char *dlerror(void) { return 0; }
-void *dlsym(void *handle, const char *symbol) { return 0; }
-int dladdr(const void *addr, Dl_info *info) { return 0; }
-int dlclose(void *handle) { return 0; }
+#include <link.h>
+#include <stdlib.h>
 
-void android_update_LD_LIBRARY_PATH(const char* ld_library_path) { }
+// These are stubs for functions that are actually defined
+// in the dynamic linker and hijacked at runtime.
+
+void* dlopen(const char* filename __unused, int flag __unused) { return 0; }
+const char* dlerror(void) { return 0; }
+void* dlsym(void* handle __unused, const char* symbol __unused) { return 0; }
+int dladdr(const void* addr __unused, Dl_info* info __unused) { return 0; }
+int dlclose(void* handle __unused) { return 0; }
+
+void android_get_LD_LIBRARY_PATH(char* buffer __unused, size_t buffer_size __unused) { }
+void android_update_LD_LIBRARY_PATH(const char* ld_library_path __unused) { }
 
 #if defined(__arm__)
-
-void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
-
+_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc __unused, int* pcount __unused) { return 0; }
 #endif
 
-/* we munge the cb definition so we don't have to include any headers here.
- * It won't affect anything since these are just symbols anyway */
-int dl_iterate_phdr(int (*cb)(void *info, void *size, void *data), void *data) { return 0; }
+int dl_iterate_phdr(int (*cb)(struct dl_phdr_info* info, size_t size, void* data) __unused, void* data __unused) { return 0; }
diff --git a/linker/Android.mk b/linker/Android.mk
index 1bf3e9d..bdc54de 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -16,7 +16,10 @@
     linker_phdr.cpp \
     rt.cpp \
 
-LOCAL_LDFLAGS := -shared -Wl,--exclude-libs,ALL
+LOCAL_LDFLAGS := \
+    -shared \
+    -Wl,-Bsymbolic \
+    -Wl,--exclude-libs,ALL \
 
 LOCAL_CFLAGS += \
     -fno-stack-protector \
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 207e03c..8501ad6 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -54,6 +54,11 @@
   return old_value;
 }
 
+void android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) {
+  ScopedPthreadMutexLocker locker(&gDlMutex);
+  do_android_get_LD_LIBRARY_PATH(buffer, buffer_size);
+}
+
 void android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
   ScopedPthreadMutexLocker locker(&gDlMutex);
   do_android_update_LD_LIBRARY_PATH(ld_library_path);
@@ -143,20 +148,6 @@
   return do_dlclose(reinterpret_cast<soinfo*>(handle));
 }
 
-#if defined(__arm__)
-//   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888 8888888
-//   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012 3456789
-#define ANDROID_LIBDL_STRTAB \
-    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_iterate_phdr\0dl_unwind_find_exidx\0"
-#elif defined(__aarch64__) || defined(__i386__) || defined(__mips__) || defined(__x86_64__)
-//   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667
-//   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890
-#define ANDROID_LIBDL_STRTAB \
-    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_iterate_phdr\0"
-#else
-#error Unsupported architecture. Only aarch64, arm, mips, x86, and x86_64 are presently supported.
-#endif
-
 // name_offset: starting index of the name in libdl_info.strtab
 #define ELF32_SYM_INITIALIZER(name_offset, value, shndx) \
     { name_offset, \
@@ -182,47 +173,55 @@
 #  define ELF_SYM_INITIALIZER ELF32_SYM_INITIALIZER
 #endif
 
+#if defined(__arm__)
+  // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1
+  // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1
+#  define ANDROID_LIBDL_STRTAB \
+    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0dl_unwind_find_exidx\0"
+#elif defined(__aarch64__) || defined(__i386__) || defined(__mips__) || defined(__x86_64__)
+  // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1
+  // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1
+#  define ANDROID_LIBDL_STRTAB \
+    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0"
+#else
+#  error Unsupported architecture. Only aarch64, arm, mips, x86, and x86_64 are presently supported.
+#endif
+
 static Elf_Sym gLibDlSymtab[] = {
   // Total length of libdl_info.strtab, including trailing 0.
   // This is actually the STH_UNDEF entry. Technically, it's
   // supposed to have st_name == 0, but instead, it points to an index
   // in the strtab with a \0 to make iterating through the symtab easier.
   ELF_SYM_INITIALIZER(sizeof(ANDROID_LIBDL_STRTAB) - 1, NULL, 0),
-  ELF_SYM_INITIALIZER( 0, &dlopen, 1),
-  ELF_SYM_INITIALIZER( 7, &dlclose, 1),
-  ELF_SYM_INITIALIZER(15, &dlsym, 1),
-  ELF_SYM_INITIALIZER(21, &dlerror, 1),
-  ELF_SYM_INITIALIZER(29, &dladdr, 1),
-  ELF_SYM_INITIALIZER(36, &android_update_LD_LIBRARY_PATH, 1),
-  ELF_SYM_INITIALIZER(67, &dl_iterate_phdr, 1),
+  ELF_SYM_INITIALIZER(  0, &dlopen, 1),
+  ELF_SYM_INITIALIZER(  7, &dlclose, 1),
+  ELF_SYM_INITIALIZER( 15, &dlsym, 1),
+  ELF_SYM_INITIALIZER( 21, &dlerror, 1),
+  ELF_SYM_INITIALIZER( 29, &dladdr, 1),
+  ELF_SYM_INITIALIZER( 36, &android_update_LD_LIBRARY_PATH, 1),
+  ELF_SYM_INITIALIZER( 67, &android_get_LD_LIBRARY_PATH, 1),
+  ELF_SYM_INITIALIZER( 95, &dl_iterate_phdr, 1),
 #if defined(__arm__)
-  ELF_SYM_INITIALIZER(83, &dl_unwind_find_exidx, 1),
+  ELF_SYM_INITIALIZER(111, &dl_unwind_find_exidx, 1),
 #endif
 };
 
 // Fake out a hash table with a single bucket.
-// A search of the hash table will look through
-// gLibDlSymtab starting with index [1], then
-// use gLibDlChains to find the next index to
-// look at.  gLibDlChains should be set up to
-// walk through every element in gLibDlSymtab,
-// and then end with 0 (sentinel value).
 //
-// That is, gLibDlChains should look like
-// { 0, 2, 3, ... N, 0 } where N is the number
-// of actual symbols, or nelems(gLibDlSymtab)-1
-// (since the first element of gLibDlSymtab is not
-// a real symbol).
+// A search of the hash table will look through gLibDlSymtab starting with index 1, then
+// use gLibDlChains to find the next index to look at. gLibDlChains should be set up to
+// walk through every element in gLibDlSymtab, and then end with 0 (sentinel value).
 //
-// (see soinfo_elf_lookup())
+// That is, gLibDlChains should look like { 0, 2, 3, ... N, 0 } where N is the number
+// of actual symbols, or nelems(gLibDlSymtab)-1 (since the first element of gLibDlSymtab is not
+// a real symbol). (See soinfo_elf_lookup().)
 //
-// Note that adding any new symbols here requires
-// stubbing them out in libdl.
+// Note that adding any new symbols here requires stubbing them out in libdl.
 static unsigned gLibDlBuckets[1] = { 1 };
 #if defined(__arm__)
-static unsigned gLibDlChains[9] = { 0, 2, 3, 4, 5, 6, 7, 8, 0 };
+static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
 #else
-static unsigned gLibDlChains[8] = { 0, 2, 3, 4, 5, 6, 7, 0 };
+static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 0 };
 #endif
 
 // This is used by the dynamic linker. Every process gets these symbols for free.
diff --git a/linker/linker.cpp b/linker/linker.cpp
index f4e426d..f58e222 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -50,13 +50,6 @@
 #include "linker_environ.h"
 #include "linker_phdr.h"
 
-/* Assume average path length of 64 and max 8 paths */
-#define LDPATH_BUFSIZE 512
-#define LDPATH_MAX 8
-
-#define LDPRELOAD_BUFSIZE 512
-#define LDPRELOAD_MAX 8
-
 /* >>> IMPORTANT NOTE - READ ME BEFORE MODIFYING <<<
  *
  * Do NOT use malloc() and friends or pthread_*() code here.
@@ -91,7 +84,7 @@
 static soinfo* sonext = &libdl_info;
 static soinfo* somain; /* main process, always the one after libdl_info */
 
-static const char* const gSoPaths[] = {
+static const char* const gDefaultLdPaths[] = {
 #if defined(__LP64__)
   "/vendor/lib64",
   "/system/lib64",
@@ -102,6 +95,12 @@
   NULL
 };
 
+#define LDPATH_BUFSIZE (LDPATH_MAX*64)
+#define LDPATH_MAX 8
+
+#define LDPRELOAD_BUFSIZE (LDPRELOAD_MAX*64)
+#define LDPRELOAD_MAX 8
+
 static char gLdPathsBuffer[LDPATH_BUFSIZE];
 static const char* gLdPaths[LDPATH_MAX + 1];
 
@@ -708,7 +707,7 @@
   // Otherwise we try LD_LIBRARY_PATH first, and fall back to the built-in well known paths.
   int fd = open_library_on_path(name, gLdPaths);
   if (fd == -1) {
-    fd = open_library_on_path(name, gSoPaths);
+    fd = open_library_on_path(name, gDefaultLdPaths);
   }
   return fd;
 }
@@ -828,6 +827,10 @@
   return 0;
 }
 
+void do_android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) {
+  snprintf(buffer, buffer_size, "%s:%s", gDefaultLdPaths[0], gDefaultLdPaths[1]);
+}
+
 void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
   if (!get_AT_SECURE()) {
     parse_LD_LIBRARY_PATH(ld_library_path);
diff --git a/linker/linker.h b/linker/linker.h
index 9afd9e1..67a86ab 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -196,6 +196,7 @@
 
 extern soinfo libdl_info;
 
+void do_android_get_LD_LIBRARY_PATH(char*, size_t);
 void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
 soinfo* do_dlopen(const char* name, int flags);
 int do_dlclose(soinfo* si);