diff options
author | Christopher Ferris <cferris@google.com> | 2019-05-07 16:02:49 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2019-05-08 12:27:56 -0700 |
commit | 235f35a26632c4c3c748f8079950bcd35f676b79 (patch) | |
tree | 10c8d4f89db6f0c6af46339ca85121f2e3047997 | |
parent | 125d32cb469d8e31f656543c3ad7b82154bc1689 (diff) | |
download | android_bionic-235f35a26632c4c3c748f8079950bcd35f676b79.tar.gz android_bionic-235f35a26632c4c3c748f8079950bcd35f676b79.tar.bz2 android_bionic-235f35a26632c4c3c748f8079950bcd35f676b79.zip |
Add removed platform functions used by apps.
Added get_malloc_leak_info and free_malloc_leak_info for arm 32 bit
only so that the kindle app will continue to run.
Bug: 132175052
Test: Ran kindle app, read pdf file. Verified libKindleReaderJNI.so
Test: is loaded in memory properly.
Change-Id: Ib1ea3a37b3729f9bcc2739c5f3a584ea8f66d200
-rw-r--r-- | libc/bionic/malloc_common_dynamic.cpp | 37 | ||||
-rw-r--r-- | libc/libc.map.txt | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp index 599ac6a58..803574649 100644 --- a/libc/bionic/malloc_common_dynamic.cpp +++ b/libc/bionic/malloc_common_dynamic.cpp @@ -500,3 +500,40 @@ extern "C" bool android_mallopt(int opcode, void* arg, size_t arg_size) { return HeapprofdMallopt(opcode, arg, arg_size); } // ============================================================================= + +#if !defined(__LP64__) && defined(__arm__) +// ============================================================================= +// Old platform only functions that some old 32 bit apps are still using. +// See b/132175052. +// Only compile the functions for 32 bit arm, so that new apps do not use +// these functions. +// ============================================================================= +extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overall_size, size_t* info_size, + size_t* total_memory, size_t* backtrace_size) { + if (info == nullptr || overall_size == nullptr || info_size == nullptr || + total_memory == nullptr || backtrace_size == nullptr) { + return; + } + + *info = nullptr; + *overall_size = 0; + *info_size = 0; + *total_memory = 0; + *backtrace_size = 0; + + android_mallopt_leak_info_t leak_info = {}; + if (android_mallopt(M_GET_MALLOC_LEAK_INFO, &leak_info, sizeof(leak_info))) { + *info = leak_info.buffer; + *overall_size = leak_info.overall_size; + *info_size = leak_info.info_size; + *total_memory = leak_info.total_memory; + *backtrace_size = leak_info.backtrace_size; + } +} + +extern "C" void free_malloc_leak_info(uint8_t* info) { + android_mallopt_leak_info_t leak_info = { .buffer = info }; + android_mallopt(M_FREE_MALLOC_LEAK_INFO, &leak_info, sizeof(leak_info)); +} +// ============================================================================= +#endif diff --git a/libc/libc.map.txt b/libc/libc.map.txt index f0fccf553..88192239a 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1713,6 +1713,8 @@ LIBC_PRIVATE { LIBC_DEPRECATED { global: __system_property_wait_any; + free_malloc_leak_info; # arm + get_malloc_leak_info; # arm }; LIBC_PLATFORM { |