OSDN Git Service

Add the dl_iterate_phdr function to libdl for arm.
authorChristopher Ferris <cferris@google.com>
Tue, 20 Aug 2013 00:45:09 +0000 (17:45 -0700)
committerChristopher Ferris <cferris@google.com>
Thu, 5 Sep 2013 22:08:22 +0000 (15:08 -0700)
Bug: 8410085
Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f

libc/arch-arm/arm.mk
libc/include/link.h
libdl/libdl.c
linker/dlfcn.cpp
linker/linker.cpp

index e87ef38..5f2443f 100644 (file)
@@ -21,10 +21,11 @@ _LIBC_ARCH_COMMON_SRC_FILES := \
 # These are used by the static and dynamic versions of the libc
 # respectively.
 _LIBC_ARCH_STATIC_SRC_FILES := \
-    arch-arm/bionic/exidx_static.c
+    arch-arm/bionic/exidx_static.c \
+    bionic/dl_iterate_phdr_static.c \
 
 _LIBC_ARCH_DYNAMIC_SRC_FILES := \
-    arch-arm/bionic/exidx_dynamic.c
+    arch-arm/bionic/exidx_dynamic.c \
 
 # Remove the C++ fortify function implementations for which there is an
 # arm assembler version.
index 842b448..0edf5df 100644 (file)
@@ -43,11 +43,11 @@ struct dl_phdr_info {
   ElfW(Half) dlpi_phnum;
 };
 
+int dl_iterate_phdr(int (*cb)(struct dl_phdr_info*, size_t, void*), void*);
+
 #ifdef __arm__
 typedef long unsigned int* _Unwind_Ptr;
 _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount);
-#else
-int dl_iterate_phdr(int (*cb)(struct dl_phdr_info*, size_t, void*), void*);
 #endif
 
 __END_DECLS
index 378f521..548364c 100644 (file)
@@ -30,12 +30,8 @@ void android_update_LD_LIBRARY_PATH(const char* ld_library_path) { }
 
 void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
 
-#elif defined(__i386__) || defined(__mips__)
+#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; }
-
-#else
-#error Unsupported architecture. Only mips, arm and x86 are supported.
-#endif
index 638164d..946f79e 100644 (file)
@@ -146,11 +146,10 @@ int dlclose(void* handle) {
 }
 
 #if defined(ANDROID_ARM_LINKER)
-//   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667
-//   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890
+//   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_unwind_find_exidx\0"
-
+    "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_iterate_phdr\0dl_unwind_find_exidx\0"
 #elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
 //   0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667
 //   0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890
@@ -181,10 +180,9 @@ static Elf32_Sym gLibDlSymtab[] = {
   ELF32_SYM_INITIALIZER(21, &dlerror, 1),
   ELF32_SYM_INITIALIZER(29, &dladdr, 1),
   ELF32_SYM_INITIALIZER(36, &android_update_LD_LIBRARY_PATH, 1),
-#if defined(ANDROID_ARM_LINKER)
-  ELF32_SYM_INITIALIZER(67, &dl_unwind_find_exidx, 1),
-#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
   ELF32_SYM_INITIALIZER(67, &dl_iterate_phdr, 1),
+#if defined(ANDROID_ARM_LINKER)
+  ELF32_SYM_INITIALIZER(83, &dl_unwind_find_exidx, 1),
 #endif
 };
 
@@ -207,7 +205,11 @@ static Elf32_Sym gLibDlSymtab[] = {
 // Note that adding any new symbols here requires
 // stubbing them out in libdl.
 static unsigned gLibDlBuckets[1] = { 1 };
+#if defined(ANDROID_ARM_LINKER)
+static unsigned gLibDlChains[9] = { 0, 2, 3, 4, 5, 6, 7, 8, 0 };
+#else
 static unsigned gLibDlChains[8] = { 0, 2, 3, 4, 5, 6, 7, 0 };
+#endif
 
 // This is used by the dynamic linker. Every process gets these symbols for free.
 soinfo libdl_info = {
@@ -223,8 +225,8 @@ soinfo libdl_info = {
     strtab: ANDROID_LIBDL_STRTAB,
     symtab: gLibDlSymtab,
 
-    nbucket: 1,
-    nchain: 8,
+    nbucket: sizeof(gLibDlBuckets)/sizeof(unsigned),
+    nchain: sizeof(gLibDlChains)/sizeof(unsigned),
     bucket: gLibDlBuckets,
     chain: gLibDlChains,
 
index 623be29..0f20181 100644 (file)
@@ -414,7 +414,7 @@ _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int *pcount)
     return NULL;
 }
 
-#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER)
+#endif
 
 /* Here, we only have to provide a callback to iterate across all the
  * loaded libraries. gcc_eh does the rest. */
@@ -437,8 +437,6 @@ dl_iterate_phdr(int (*cb)(dl_phdr_info *info, size_t size, void *data),
     return rv;
 }
 
-#endif
-
 static Elf32_Sym* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name) {
     Elf32_Sym* symtab = si->symtab;
     const char* strtab = si->strtab;