2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
ビルド済み ABI 使用状況チェッカー
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 共有ライブラリは、随時進化しています。ビルド済みのバイナリを最新の状態に保つにはかなりの労力が必要です。Android 9 以前では、削除されたライブラリや ABI に依存するビルド済みのバイナリはランタイムでのリンク失敗となるしかありませんでした。デベロッパーは、古くなったビルド済みバイナリを検出するためにログをトレースする必要がありました。Android 10 では、シンボルベースの ABI 使用状況チェッカーが導入されています。このチェッカーは、ビルド時に古くなったビルド済みのバイナリを検出できるので、共有ライブラリのデベロッパーは、変更により無効となった可能性のあるビルド済みのバイナリと、ビルドし直す必要のあるバイナリを判断できます。
シンボルベースの ABI 使用状況チェッカー
シンボルベースの ABI 使用状況チェッカーは、ホスト上の Android ダイナミック リンカーをエミュレートします。
チェッカーは、ビルド済みのバイナリをその依存関係とリンクし、すべての未定義のシンボルが解決したかどうかを確認します。
はじめに、チェッカーはビルド済みバイナリのターゲット アーキテクチャを確認します。ビルド済みバイナリのターゲットが ARM、AArch64、x86、x86-64 アーキテクチャでない場合、チェッカーはそのビルド済みバイナリをスキップします。
次に、ビルド済みバイナリの依存関係が LOCAL_SHARED_LIBRARIES
または shared_libs
で指定されていることを確認します。ビルドシステムは、モジュール名を共有ライブラリの一致するバリアント(例: core
か vendor
か)に解決します。
3 番目に、チェッカーは、DT_NEEDED
エントリを LOCAL_SHARED_LIBRARIES
または shared_libs
と比較します。具体的には、チェッカーは DT_SONAME
エントリを各共有ライブラリから抽出し、これらの DT_SONAME
をビルド済みのバイナリに記録された DT_NEEDED
エントリと比較します。不一致がある場合は、エラー メッセージが出ます。
4 番目に、チェッカーは、ビルド済みのバイナリの未定義シンボルを解決します。これらの未定義のシンボルは、依存関係のいずれか 1 つに定義される必要があり、シンボル バインディングは GLOBAL
または WEAK
である必要があります。未定義のシンボルを解決できない場合は、エラー メッセージが出力されます。
モジュールのプロパティを事前にビルドする
ビルド済みのバイナリの依存関係は、次のいずれか 1 つに指定する必要があります。
- Android.bp:
shared_libs: ["libc", "libdl", "libm"],
- Android.mk:
LOCAL_SHARED_LIBRARIES := libc libdl libm
ビルド済みのバイナリが未解決の未定義シンボルを持つように設計されている場合は、次のいずれかを指定します。
- Android.bp:
allow_undefined_symbols: true,
- Android.mk:
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
ビルド済みバイナリへの ELF ファイル チェックをスキップするには、次のいずれかを指定します。
- Android.bp:
check_elf_files: false,
- Android.mk:
LOCAL_CHECK_ELF_FILES := false
チェッカーを実行する
チェッカーは、Android ビルドプロセスにおけるすべての ELF ビルド済みモジュールに対応しています。
チェッカーを単独で実行して処理時間を短縮するには:
m check-elf-files
ABI エラー修正ツール
自動修正ツールは ABI チェックエラーの解決に役立ちます。Android.bp / Android.mk を入力として修正ツールを実行すると、修正候補が stdout に出力されます。必要に応じて、--in-place
オプションを指定して修正ツールを実行すると、修正候補を使用して Android.bp / Android.mk が直接更新されます。
Android.bp の場合:
m fix_android_bp_prebuilt
# Print the fixed Android.bp to stdout.
fix_android_bp_prebuilt <path-to-Android.bp>
# Update the Android.bp in place.
fix_android_bp_prebuilt --in-place <path-to-Android.bp>
Android.mk の場合:
m fix_android_mk_prebuilt
# Print the fixed Android.mk to stdout.
fix_android_mk_prebuilt <path-to-Android.mk>
# Update the Android.mk in place.
fix_android_mk_prebuilt --in-place <path-to-Android.mk>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Prebuilt ABI usages checker\n\nAndroid shared libraries evolve from time to time. Keeping prebuilt binaries\nup-to-date requires considerable effort. In Android 9\nor earlier, the prebuilt binaries that depend on removed libraries or ABIs only\nfail to link at run-time. Developers have to trace the logs to find the outdated\nprebuilt binaries. In Android 10, a symbol-based ABI\nusages checker is introduced. The checker can detect outdated prebuilt binaries\nat build-time, so that shared library developers can know which prebuilt\nbinaries might be broken by their change and which prebuilt binaries must be\nre-built.\n\nSymbol-based ABI usages checker\n-------------------------------\n\nThe symbol-based ABI usages checker emulates the Android dynamic linker on host.\nThe checker links the prebuilt binary with the dependencies of the prebuilt\nbinary and checks whether all undefined symbols are resolved.\n\nFirst, the checker checks the target architecture of the prebuilt binary. If the\nprebuilt binary does not target ARM, AArch64, x86, or x86-64 architecture, the\nchecker skips the prebuilt binary.\n\nSecond, the dependencies of the prebuilt binary must be listed in\n`LOCAL_SHARED_LIBRARIES` or `shared_libs`. The build system resolves the module\nnames to the matching variant (i.e. `core` vs. `vendor`) of the shared\nlibraries.\n\nThird, the checker compares the `DT_NEEDED` entries to `LOCAL_SHARED_LIBRARIES`\nor `shared_libs`. In particular, the checker extracts the `DT_SONAME` entry from\neach shared libraries and compares these `DT_SONAME` with the `DT_NEEDED`\nentries recorded in the prebuilt binary. If there is a mismatch, an error\nmessage is emitted.\n\nFourth, the checker resolves the undefined symbols in the prebuilt binary. Those\nundefined symbols must be defined in one of the dependencies and the symbol\nbinding must be either `GLOBAL` or `WEAK`. If an undefined symbol cannot be\nresolved, an error message is emitted.\n\nPrebuilts module properties\n---------------------------\n\nDependencies of the prebuilt binary must be specified in one of the following:\n\n- Android.bp: `shared_libs: [\"libc\", \"libdl\", \"libm\"],`\n- Android.mk: `LOCAL_SHARED_LIBRARIES := libc libdl libm`\n\nIf the prebuilt binary is designed to have some **unresolvable undefined\nsymbols**, specify one of the following:\n\n- Android.bp: `allow_undefined_symbols: true,`\n- Android.mk: `LOCAL_ALLOW_UNDEFINED_SYMBOLS := true`\n\nTo have the prebuilt binary skip the ELF file check, specify one of the\nfollowing:\n\n- Android.bp: `check_elf_files: false,`\n- Android.mk: `LOCAL_CHECK_ELF_FILES := false`\n\nRun the checker\n---------------\n\nThe checker covers all ELF prebuilt modules during the Android build process.\n\nTo run the checker alone for faster turnaround times: \n\n m check-elf-files\n\nABI error fixer\n---------------\n\nThe automatic fixer can help resolve ABI check errors. Simply run the fixer with\nthe Android.bp / Android.mk as input, and the fixer would print the suggested\nfix to stdout. Optionally, run the fixer with the `--in-place` option to\ndirectly update the Android.bp / Android.mk with the suggested fix.\n\nFor Android.bp, \n\n m fix_android_bp_prebuilt\n # Print the fixed Android.bp to stdout.\n fix_android_bp_prebuilt \u003cpath-to-Android.bp\u003e\n # Update the Android.bp in place.\n fix_android_bp_prebuilt --in-place \u003cpath-to-Android.bp\u003e\n\nFor Android.mk, \n\n m fix_android_mk_prebuilt\n # Print the fixed Android.mk to stdout.\n fix_android_mk_prebuilt \u003cpath-to-Android.mk\u003e\n # Update the Android.mk in place.\n fix_android_mk_prebuilt --in-place \u003cpath-to-Android.mk\u003e"]]