Skip to content

Commit

Permalink
Merge pull request #1 from shizhx/fix_readelf_missing
Browse files Browse the repository at this point in the history
Fix readelf missing
  • Loading branch information
shizhx authored Nov 28, 2022
2 parents bdf1f77 + 490994a commit 9d5f34a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

rm "LogDisablerLite.zip"
pushd src || exit 1
mkdir -p ./system/lib64
zip -r "../LogDisablerLite.zip" ./*
popd || exit 2
14 changes: 10 additions & 4 deletions src/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,30 @@ PATCHED_LIB="liblog_patched.so"
# echo "$*"
# }


READELF="${MODPATH}/toybox-aarch64 readelf"
if ! chmod a+x "${MODPATH}/toybox-aarch64"; then
abort "Failed to chmod a+x ${MODPATH}/toybox-aarch64"
fi

# copy to TMPDIR
if ! cp -f "${TARGET_DIR}/${TARGET_LIB}" "${TMPDIR}/${TARGET_LIB}"; then
abort "Failed to copy ${TARGET_DIR}/${TARGET_LIB} to ${TMPDIR}/${TARGET_LIB}"
fi
ui_print "Success to copy ${TARGET_DIR}/${TARGET_LIB} to ${TMPDIR}/${TARGET_LIB}"

# parse liblog.so to get the virtual address of __android_log_is_loggable
TARGET_FUNC_VADDR=$(readelf -sW "${TMPDIR}/${TARGET_LIB}" | grep -w __android_log_is_loggable | awk '{print $2}')
if [ -z "$TARGET_FUNC_VADDR" ]; then
TARGET_FUNC_VADDR=$($READELF -sW "${TMPDIR}/${TARGET_LIB}" | grep -w __android_log_is_loggable | awk '{print $2}')
if [ $? -ne 0 ] || [ -z "$TARGET_FUNC_VADDR" ]; then
abort "Failed to get virtual address of __android_log_is_loggable from ${TMPDIR}/${TARGET_LIB}"
fi
ui_print "Success to get virtual address of __android_log_is_loggable: ${TARGET_FUNC_VADDR}"
# Example vaddr 00000000000089ac, so add '0x' prefix to it and convert to number
TARGET_FUNC_VADDR=$(printf "%ld" "0x${TARGET_FUNC_VADDR}")

# parse liblog.so to get elf headers
HEADERS=$(readelf -l "${TMPDIR}/${TARGET_LIB}" | sed '/Program Headers/,/Section to Segment mapping/!d;/Program Headers/d;/Section to Segment mapping/d')
if [ -z "$HEADERS" ]; then
HEADERS=$($READELF -l "${TMPDIR}/${TARGET_LIB}" | sed '/Program Headers/,/Section to Segment mapping/!d;/Program Headers/d;/Section to Segment mapping/d')
if [ $? -ne 0 ] || [ -z "$HEADERS" ]; then
abort "Failed to parse program headers from ${TMPDIR}/${TARGET_LIB}"
fi

Expand Down
4 changes: 2 additions & 2 deletions src/module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=logddisablerlite
name=LogDisablerLite
version=1.2
versionCode=3
version=1.3
versionCode=4
author=shizhx@github
description=Disable Logging to logcat
Binary file added src/toybox-aarch64
Binary file not shown.

0 comments on commit 9d5f34a

Please sign in to comment.