天天看點

error: only position independent executables (PIE) are supported.

root@hlte:/data/local # ./tcpdump -p -s 0                                       
error: only position independent executables (PIE) are supported.
           

由于使用了NDK編譯的可執行檔案在應用中調用,在4.4及之前的版本上一直沒出問題。最近由于要測試在Android L上的運作情況發現,當運作該可執行檔案時,報上面的錯誤。

PIE這個安全機制從4.1引入,但是Android L之前的系統版本并不會去檢驗可執行檔案是否基于PIE編譯出的。是以不會報錯。但是Android L已經開啟驗證,如果調用的可執行檔案不是基于PIE方式編譯的,則無法運作。解決辦法是在Android.mk中加入如下flag就行。

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
           
基于tcpdump的Android智能移動終端資料包捕獲完整解決方案 Android tcpdump抓包應用實作 Android通過tcpdump抓包

繼續閱讀