Android shared libraries evolve from time to time. Keeping prebuilt binaries up-to-date requires considerable effort. In Android 9 or earlier, the prebuilt binaries that depend on removed libraries or ABIs only fail to link at run-time. Developers have to trace the logs to find the outdated prebuilt binaries. In Android 10, a symbol-based ABI usages checker is introduced. The checker can detect outdated prebuilt binaries at build-time, so that shared library developers can know which prebuilt binaries might be broken by their change and which prebuilt binaries must be re-built.
Symbol-based ABI usages checker
The symbol-based ABI usages checker emulates the Android dynamic linker on host. The checker links the prebuilt binary with the dependencies of the prebuilt binary and checks whether all undefined symbols are resolved.
First, the checker checks the target architecture of the prebuilt binary. If the prebuilt binary does not target ARM, AArch64, x86, or x86-64 architecture, the checker skips the prebuilt binary.
Second, the dependencies of the prebuilt binary must be listed in
shared_libs. The build system resolves the module
names to the matching variant (i.e.
vendor) of the shared
Third, the checker compares the
DT_NEEDED entries to
shared_libs. In particular, the checker extracts the
DT_SONAME entry from
each shared libraries and compares these
DT_SONAME with the
entries recorded in the prebuilt binary. If there is a mismatch, an error
message is emitted.
Fourth, the checker resolves the undefined symbols in the prebuilt binary. Those
undefined symbols must be defined in one of the dependencies and the symbol
binding must be either
WEAK. If an undefined symbol cannot be
resolved, an error message is emitted.
Prebuilts module properties
Dependencies of the prebuilt binary must be specified in one of the following:
shared_libs: ["libc", "libdl", "libm"],
LOCAL_SHARED_LIBRARIES := libc libdl libm
If the prebuilt binary is designed to have some unresolvable undefined symbols, specify one of the following:
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
To have the prebuilt binary skip the ELF file check, specify one of the following:
LOCAL_CHECK_ELF_FILES := false
Run the checker
The checker covers all ELF prebuilt modules during the Android build process.
To run the checker alone for faster turnaround times:
ABI error fixer
The automatic fixer can help resolve ABI check errors. Simply run the fixer with
the Android.bp / Android.mk as input, and the fixer would print the suggested
fix to stdout. Optionally, run the fixer with the
--in-place option to
directly update the Android.bp / Android.mk with the suggested fix.
# Print the fixed Android.bp to stdout.
# Update the Android.bp in place.
fix_android_bp_prebuilt --in-place <path-to-Android.bp>
# Print the fixed Android.mk to stdout.
# Update the Android.mk in place.
fix_android_mk_prebuilt --in-place <path-to-Android.mk>