OSDN Git Service

Re-add dlmalloc for 32 bit.
authorChristopher Ferris <cferris@google.com>
Thu, 9 Oct 2014 05:48:20 +0000 (22:48 -0700)
committerChristopher Ferris <cferris@google.com>
Thu, 9 Oct 2014 18:47:01 +0000 (11:47 -0700)
It turns out that appportable has a version that calls dlmalloc directly.
Re-add the dlmalloc symbol for 32 bit only as a compatibility shim that
calls malloc.

Bug: 17881362

(cherry pick commit from c9734d24d92f4737f5ab3808c77d816a1b084582)

Change-Id: Iee9a777f66a1edb407d7563a60792b767ac4f83a

libc/bionic/dlmalloc.h
libc/bionic/ndk_cruft.cpp

index ef78814..2f53c1b 100644 (file)
 
 #define malloc_getpagesize getpagesize()
 
-/* dlmalloc_usable_size was exposed in the NDK, so change the name
- * of the function on 32 bit architectures.
- */
 #if !defined(__LP64__)
+/* dlmalloc_usable_size and dlmalloc were exposed in the NDK and some
+ * apps actually used them. Rename these functions out of the way
+ * for 32 bit architectures so that ndk_cruft.cpp can expose
+ * compatibility shims with these names.
+ */
 #define dlmalloc_usable_size dlmalloc_usable_size_real
+#define dlmalloc dlmalloc_real
 #endif
 
 /* Export two symbols used by the VM. */
index 2cd2e33..18a4a14 100644 (file)
@@ -325,4 +325,10 @@ extern "C" pid_t __pthread_gettid(pthread_t t) {
   return pthread_gettid_np(t);
 }
 
+// Older versions of appportable used dlmalloc directly instead of malloc,
+// so export this compatibility shim that simply calls malloc.
+extern "C" void* dlmalloc(size_t size) {
+  return malloc(size);
+}
+
 #endif