天天看點

NDK編譯程式運作出現 unused DT entry 錯誤

使用 NDK 制作的編譯工具鍊編譯出可執行檔案後,傳到 Android 中運作的時候,會出現如下的 WARNING 資訊:

WARNING: linker: liblxc.so: unused DT entry: type 0x6ffffffe arg 0x8c04
WARNING: linker: liblxc.so: unused DT entry: type 0x6fffffff arg 0x1
           

提示資訊可能有些資料不相同,但都屬于 unused DT entry 問題;

官方已經給出了詳細的說明、原因以及警告的類型,而且從 Android5.1開始,就會警告 verneed 和 verneednum 的問題;

下面給出解決方法:

  1. 制作 android_elf_cleaner 工具

    1) github位址下載下傳android_elf_cleaner

    git clone https://github.com/kost/android-elf-cleaner.git
               
    如下載下傳速度過慢可參考 https://blog.csdn.net/qq_30123335/article/details/116602517
               
    2)直接在 linux 中執行 make 指令,即可編譯得到 android-elf-cleaner 可執行程式
    cd android_elf_cleaner
    make 
               
  2. 處理一下編譯出來的可執行檔案,再次運作即可消除此問題
    usage: ./android-elf-cleaner <filename>
           Processes ELF files to remove DT_VERNEEDED, DT_VERNEEDNUM, DT_RPATH
           and DT_RUNPATH entries (which the Android linker warns about)
               

結果如下:

NDK編譯程式運作出現 unused DT entry 錯誤