在做 Android Porting 的時候,我們修改的 liblog
而在調試的時候,我用 gcc -E 展開 LOGE的調用就是 __android_log_print
它隻在 system/core/liblog/logd_write.c, 但我每次修改 __android_log_print 都不生效
因此我懷疑有別的 symbol 取代瞭它
用readelf 查看,果然 liblog.so 中有的symbol, 在 libcutils 中也有
$ /opt/broadcom/stbgcc-4.5.3-2.4/bin/mipsel-linux-readelf -s out/target/product/alien_broadcom_stb/system/lib/liblog.so | grep print 10: 0000328c 324 FUNC GLOBAL DEFAULT 9 android_log_printLogLine 15: 00001c28 160 FUNC GLOBAL DEFAULT 9 __android_log_print 18: 00001cc8 144 FUNC GLOBAL DEFAULT 9 __android_log_buf_print 21: 00001bb8 112 FUNC GLOBAL DEFAULT 9 __android_log_vprint 27: 000033d0 444 FUNC GLOBAL DEFAULT 9 logprint_run_tests 34: 00005950 0 FUNC GLOBAL DEFAULT UND printf 42: 000058f0 0 FUNC GLOBAL DEFAULT UND vsnprintf 45: 000058c0 0 FUNC GLOBAL DEFAULT UND fprintf 71: 000057f0 0 FUNC GLOBAL DEFAULT UND snprintf $ /opt/broadcom/stbgcc-4.5.3-2.4/bin/mipsel-linux-readelf -s out/target/product/alien_broadcom_stb/system/lib/libcutils | grep print payne@payne-desktop:~/bjb$ /opt/broadcom/7425b2/stbgcc-4.5.3-2.4/bin/mipsel-linux-readelf -s out/target/product/alien_broadcom_stb/system/lib/libcutils.so | grep print 40: 00006078 324 FUNC GLOBAL DEFAULT 9 android_log_printLogLine 68: 00010670 8 FUNC GLOBAL DEFAULT 9 mspace_footprint 81: 00004ab4 144 FUNC GLOBAL DEFAULT 9 __android_log_buf_print 110: 000049c4 112 FUNC GLOBAL DEFAULT 9 __android_log_vprint 142: 000106c4 8 FUNC GLOBAL DEFAULT 9 mspace_max_footprint 149: 000061bc 444 FUNC GLOBAL DEFAULT 9 logprint_run_tests 204: 000187a0 0 FUNC GLOBAL DEFAULT UND sprintf 206: 00018790 0 FUNC GLOBAL DEFAULT UND vsnprintf 215: 00018720 0 FUNC GLOBAL DEFAULT UND fprintf 246: 00018670 0 FUNC GLOBAL DEFAULT UND asprintf 276: 00004a34 128 FUNC GLOBAL DEFAULT 9 __android_log_print 284: 00018520 0 FUNC GLOBAL DEFAULT UND snprintf
參看瞭 libcutils 的Android.mk, 它果然把 liblog 的靜態庫,加入到自己。程序運行的 libcutils 中 __android_log_print 始終沒有更新,所以看不到改動結果。
因此,每次用 mmm system/core/liblog 重編譯 liblog的時候,也要同時用 mmm system/core/libcutils 更新 libctils