From 906dbea2b4120ebc4113b4faf81d789ef04ea7b2 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 22 Feb 2012 15:18:54 -0800 Subject: [PATCH 1/5] libc: Add __aeabi_llsl and __aeabi_llsr to libgcc_compat Some platform libraries built for ICS do not work with master because of some refactoring in frameworks/base. Make sure that these libgcc symbols are always present in our libc Change-Id: Ib8d345878be0ba711f051082a778f5cc1f1b3a19 Signed-off-by: Dima Zavin --- libc/arch-arm/bionic/libgcc_compat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc/arch-arm/bionic/libgcc_compat.c b/libc/arch-arm/bionic/libgcc_compat.c index d184566c9..1a1970103 100644 --- a/libc/arch-arm/bionic/libgcc_compat.c +++ b/libc/arch-arm/bionic/libgcc_compat.c @@ -113,6 +113,8 @@ XX(__aeabi_l2d) \ XX(__aeabi_l2f) \ XX(__aeabi_lmul) \ + XX(__aeabi_llsl) \ + XX(__aeabi_llsr) \ XX(__aeabi_ui2d) \ XX(__aeabi_ui2f) \ XX(__aeabi_ul2d) \ From 93b8f941f2de1bd110265dd7585710ac30548928 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 24 Feb 2012 11:04:42 -0800 Subject: [PATCH 2/5] Revert "Use the new NativeDaemonConnector style." The other changes relating to this were already reverted. This reverts commit 1625c7a837d73b6729f97edb32c497d289c0220c --- libc/netbsd/net/getaddrinfo.c | 2 +- libc/netbsd/net/getnameinfo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c index 6aee69741..6ae6e3e43 100644 --- a/libc/netbsd/net/getaddrinfo.c +++ b/libc/netbsd/net/getaddrinfo.c @@ -461,7 +461,7 @@ android_getaddrinfo_proxy( // Send the request. proxy = fdopen(sock, "r+"); - if (fprintf(proxy, "0 getaddrinfo %s %s %d %d %d %d", + if (fprintf(proxy, "getaddrinfo %s %s %d %d %d %d", hostname == NULL ? "^" : hostname, servname == NULL ? "^" : servname, hints == NULL ? -1 : hints->ai_flags, diff --git a/libc/netbsd/net/getnameinfo.c b/libc/netbsd/net/getnameinfo.c index 313b2bf36..d3d0011b9 100644 --- a/libc/netbsd/net/getnameinfo.c +++ b/libc/netbsd/net/getnameinfo.c @@ -187,7 +187,7 @@ android_gethostbyaddr_proxy(struct hostent* hp, const void *addr, socklen_t addr if (addrStr == NULL) { goto exit; } - if (fprintf(proxy, "0 gethostbyaddr %s %d %d", addrStr, addrLen, addrFamily) < 0) { + if (fprintf(proxy, "gethostbyaddr %s %d %d", addrStr, addrLen, addrFamily) < 0) { goto exit; } From fa3f72ee53ba79e41b78fa178ef8bb9372e2c084 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Mon, 5 Mar 2012 10:45:31 -0800 Subject: [PATCH 3/5] Revert "Reference __dso_handle in PIC way" This reverts commit 93cb30813764b140f0adbaa620dcdbb1cae56dd8 --- libc/arch-arm/bionic/crtbegin_so.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libc/arch-arm/bionic/crtbegin_so.S b/libc/arch-arm/bionic/crtbegin_so.S index 8123254ea..9275b1e01 100644 --- a/libc/arch-arm/bionic/crtbegin_so.S +++ b/libc/arch-arm/bionic/crtbegin_so.S @@ -34,18 +34,17 @@ # standard. # __on_dlclose: - ldr r0, .L1 -.LPIC0: - add r0, pc + adr r0, 0f ldr r0, [r0] b __cxa_finalize -.L1: - .word __dso_handle-(.LPIC0+4) - .section .init_array, "aw" - .globl __INIT_ARRAY__ +0: + .long __dso_handle + + .section .init_array, "aw" + .globl __INIT_ARRAY__ __INIT_ARRAY__: - .long -1 + .long -1 .section .fini_array, "aw" .globl __FINI_ARRAY__ From ad7ff82771b44ad36d2a66c2413dffaff20816e9 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 10 Apr 2012 13:42:06 -0700 Subject: [PATCH 4/5] Revert "linker: remove STB_LOCAL hack" This reverts commit 61ff83475c6f3a3bb05a01ac89d668a331bfe9e9. This code is harmless, and only applies to the linker, so there's no harm in keeping it in the tree a little bit longer. Let's roll this back while we try to figure out the root cause of bug 6314858. Bug: 6314858 Change-Id: I9f5ed81d23a7abe273baf792aa8a0a2839ef094c --- linker/linker.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/linker/linker.c b/linker/linker.c index ac183fdaa..9805b35e3 100644 --- a/linker/linker.c +++ b/linker/linker.c @@ -408,6 +408,33 @@ static Elf32_Sym *_elf_lookup(soinfo *si, unsigned hash, const char *name) return NULL; } +/* + * Essentially the same method as _elf_lookup() above, but only + * searches for LOCAL symbols + */ +static Elf32_Sym *_elf_lookup_local(soinfo *si, unsigned hash, const char *name) +{ + Elf32_Sym *symtab = si->symtab; + const char *strtab = si->strtab; + unsigned n = hash % si->nbucket;; + + TRACE_TYPE(LOOKUP, "%5d LOCAL SEARCH %s in %s@0x%08x %08x %d\n", pid, + name, si->name, si->base, hash, hash % si->nbucket); + for(n = si->bucket[hash % si->nbucket]; n != 0; n = si->chain[n]){ + Elf32_Sym *s = symtab + n; + if (strcmp(strtab + s->st_name, name)) continue; + if (ELF32_ST_BIND(s->st_info) != STB_LOCAL) continue; + /* no section == undefined */ + if(s->st_shndx == 0) continue; + + TRACE_TYPE(LOOKUP, "%5d FOUND LOCAL %s in %s (%08x) %d\n", pid, + name, si->name, s->st_value, s->st_size); + return s; + } + + return NULL; +} + static unsigned elfhash(const char *_name) { const unsigned char *name = (const unsigned char *) _name; @@ -431,6 +458,16 @@ _do_lookup(soinfo *si, const char *name, unsigned *base) soinfo *lsi = si; int i; + /* If we are trying to find a symbol for the linker itself, look + * for LOCAL symbols first. Avoid using LOCAL symbols for other + * shared libraries until we have a better understanding of what + * might break by doing so. */ + if (si->flags & FLAG_LINKER) { + s = _elf_lookup_local(si, elf_hash, name); + if(s != NULL) + goto done; + } + /* Look for symbols in the local scope (the object who is * searching). This happens with C++ templates on i386 for some * reason. From 2481468f2232b1d9670657e0148c434c3359ce19 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Thu, 24 May 2012 16:56:53 -0700 Subject: [PATCH 5/5] Print the corrupted address passed to free(). For example: @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x5c3bfbd0 Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2942 The addr=0x5c3bfbd0 part is new. Change-Id: I8670144b2b0a3a6182384150d762c97dfee5452f --- libc/bionic/dlmalloc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c index 98ea9e93b..ec76acffc 100644 --- a/libc/bionic/dlmalloc.c +++ b/libc/bionic/dlmalloc.c @@ -2290,7 +2290,22 @@ static void reset_on_error(mstate m); # include -static void __bionic_heap_error(const char* msg, const char* function) +/* Convert a pointer into hex string */ +static void __bionic_itox(char* hex, void* ptr) +{ + intptr_t val = (intptr_t) ptr; + /* Terminate with NULL */ + hex[8] = 0; + int i; + + for (i = 7; i >= 0; i--) { + int digit = val & 15; + hex[i] = (digit <= 9) ? digit + '0' : digit - 10 + 'a'; + val >>= 4; + } +} + +static void __bionic_heap_error(const char* msg, const char* function, void* p) { /* We format the buffer explicitely, i.e. without using snprintf() * which may use malloc() internally. Not something we can trust @@ -2303,17 +2318,25 @@ static void __bionic_heap_error(const char* msg, const char* function) strlcat(buffer, " IN ", sizeof(buffer)); strlcat(buffer, function, sizeof(buffer)); } + + if (p != NULL) { + char hexbuffer[9]; + __bionic_itox(hexbuffer, p); + strlcat(buffer, " addr=0x", sizeof(buffer)); + strlcat(buffer, hexbuffer, sizeof(buffer)); + } + __libc_android_log_write(ANDROID_LOG_FATAL,"libc",buffer); abort(); } # ifndef CORRUPTION_ERROR_ACTION # define CORRUPTION_ERROR_ACTION(m) \ - __bionic_heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__) + __bionic_heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__, 0) # endif # ifndef USAGE_ERROR_ACTION # define USAGE_ERROR_ACTION(m,p) \ - __bionic_heap_error("INVALID HEAP ADDRESS", __FUNCTION__) + __bionic_heap_error("INVALID HEAP ADDRESS", __FUNCTION__, p) # endif #else /* !LOG_ON_HEAP_ERROR */