1. 程式人生 > 其它 >ldd 執行結果:不是動態可執行檔案

ldd 執行結果:不是動態可執行檔案

技術標籤:# shell# 技巧

問題產生

最近,在移植 busybox 到 ARM 板,啟動時報錯

/linuxrc: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
Kernel panic - not syncing: Attempted to kill init!

原因是缺少動態庫,想到 busybox 應該不止依賴這一個庫,想一次把所有依賴的動態庫都拷貝過去,於是使用 ldd 檢視 busybox 都依賴了哪些動態庫,結果翻車了

$ ldd bin/busybox 
	不是動態可執行檔案

心想可能因為這是 arm 32 位的可執行檔案,使用 arm-linux-ldd 試下呢

$ arm-linux-ldd bin/busybox 
arm-linux-ldd: no root given
Try ` --help' for more information
 >&2

依舊不行

解決

後來想到 readelf 好像也可以看到依賴的動態庫

$ readelf -d bin/busybox | grep NEEDED
 0x00000001 (NEEDED)                     共享庫:[libm.so.6]
0x00000001 (NEEDED) 共享庫:[libresolv.so.2] 0x00000001 (NEEDED) 共享庫:[librt.so.1] 0x00000001 (NEEDED) 共享庫:[libc.so.6]

果然,可以。