Skip to content

Debugging dynamic libraries loading problems in Android

Get the output information of linker

After building from sources (AOSP 9.0). it can be done by setting LD_DEBUG flag when

export LD_DEBUG=3

The value of LD_DEBUG means:

  • 0 : default -> logcat Fatal
  • 1 : info -> logcat Warning
  • 2 : trace -> logcat Info
  • 3 : debug -> logcat Debug (potentially lots of logging)

Use following command to show the linker messages:

adb logcat -s linker

Then, it will output messages like below

06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/system/lib64/liblog.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/vendor/lib64/libc++_shared.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/apex/com.android.runtime/lib64/bionic/libm.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/apex/com.android.runtime/lib64/bionic/libdl.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/apex/com.android.runtime/lib64/bionic/libc.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/system/lib64/libc++.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/system/lib64/libhidlbase.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/system/lib64/libhardware.so" ]
06-03 06:41:51.340 20397 20397 W linker  : [ Linking "/system/lib64/libutils.so" ]
Leave a Reply