最近在做tcu 的項目,重新移植了文件系統。運行客戶的提供的程序報錯:
和客戶溝通,交叉編譯工具版本是一致的,感覺是缺少動態庫
用dd命令查看,但是這ldd無法顯示,
developer-RH2485-V2:$ ldd qrencode
not a dynamic executable
在網上看了看 ,找到了一種方式 使用readelf
readelf -l qrencode | grep ld-linux
[Requesting program interpreter: /lib/ld-linux-armhf.so.3
說明運行該文件需要/lib/ld-linux-armhf.so.3文件。
查看/lib目錄,在 lib目錄下確實沒用ld-linux-armhf.so.3
在lib目錄下建立軟鏈接
ln -s ld-2.19-2014.08-1-git.so ld-linux-armhf.so.3
sync
再次運行
解決!
在板子上通過file命令查看 報錯和不報錯的二進制
可以看出兩者的interpreter(解釋器)不同。解釋器負責加載動態庫
readelf命令是Linux下的分析ELF文件的命令,這個命令在分析ELF文件格式時非常有用,下面以ELF格式可執行文件test爲例詳細介紹: readelf -v 顯示版本 readelf -h 顯示幫助 readelf -a test 顯示test的全部信息 readelf -h test 顯示test的ELF Header的文件頭信息(就是ELF文件開始的前52個字節) readelf -l test 顯示test的Program Header Table中的每個Prgram Header Entry的信息(如果有) readelf -S test 顯示test的Section Header Table中的每個Section Header Entry的信息(如果有) readelf -g test 顯示test的Section Group的信息(如果有) readelf -s test 顯示test的Symbol Table中的每個Symbol Table Entry的信息(如果有) readelf -e test 顯示test的全部頭信息(包括ELF Header,Section Header和Program Header,等同與 readelf -h -l -S test) readelf -n test 顯示test的note段的信息(如果有) readelf -r test 顯示test中的可重定位段的信息(如果有) readelf -d test 顯示test中的Dynamic Section的信息(如果有) readelf -V test 顯示test中的GNU Version段信息(如果有) 其實上述的命令只是把ELF文件格式的不同部分輸出而已,只要瞭解ELF文件格式後這些命令就不難了啦~~