Bionic: Fix some issues in chk_malloc

1. Revise log_message in chk_malloc
a) Race condition issues may occur when malloc/free are dispatched between
dlmalloc/dlfree and chk_malloc/chk_free when libc.debug.malloc=10 is set.

log_message reverts chk_malloc/chk_free to default dlmalloc/dlfree, but
that's not safe if other threads are trying to call malloc/free. This
may lead mismatched to chk_malloc/chk_free and malloc/free calls. Use a
lock instead.

b) But still a potential deadlock (recursively call the same non-recursive-lock)
with backlog_lock/lock will occur if log_message called from chk_malloc
/chk_free tries to call chk_malloc/chk_free again.

In mem chunk meta, ALLOC_NONCHK_TAG is added to avoid chunks allocated
in log_message being added to the memleak/doublefree track lists and
being checked to make sure no non-recur-lock will be called recursively.

2. Race issue in heaptracker
a) Travel the list in heaptracker_free_leaked_memory() without fully
holding locks will result in race condition.
Locks are added to deal with it.

b) If corruptions were found without removing the chunk from the chunk list
e.g. backlog list, list corruptions will come out with broken list pointers
as dlfree will change the meta data.
abort() will be called directly after corruptions are found in
check_allocation_locked() to report errors as early as possible.

3. Align chk_realloc with dlrealloc
The old mem pointer passed to chk_realloc should be checked first especially
when the size equals to zero. If not, chk_realloc will return NULL which
means no mem left and results in fatal errors.
This change will align chk_realloc with dlrealloc.
REALLOC_ZERO_BYTES_FREES defined in bionic/libc/Android.mk is also added
into chk_malloc to keep alignment.

Change-Id: I537bdf7df98bb00dc504a9d3fd0a54f9ddcd9295
Author: Du Chenyang <chenyang.du@intel.com>
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Author-tracking-BZ: 53674
fix memory leak(s)

Change-Id: I2a407cf499f995fe080d855bd18fef41e93fa52c
Remove some dead script code and fix a script comment.

Change-Id: I91ca466d1b6f8a39da50ce61acebc268d0daab3a
Add __aeabi_idiv to the dummy reference list.

If the platform code is compiled with -mcpu=cortex-a15, then without this
change prebuilt libraries built against -march=armv7 cannot resolve the
dependency on __aeabi_idiv (provided by libgcc.a).

Bug: 7961327

cherry-picked from internal master.

Change-Id: I8fe59a98eb53d641518b882523c1d6a724fb7e55