2012-07-08 123 views
7

可以在其他具有Linux的ARM設備(如Raspberry Pi)上運行爲Android構建的ARM二進制文件(不是.apk)?我試圖在ARM上移植我的一個項目,但我需要使用僅適用於x86(Windows和Linux)和(最近)的Android設備的封閉源二進制文件(SopCast)。在Linux上運行適用於Android的ARM二進制文件ARM

運行file sopclient顯示ELF 32位LSB的可執行文件,ARM,版本1(SYSV),動態鏈接(使用共享庫),剝離sh sopclient說只是不能執行二進制文件(是的,我chmoded + X它之前)。

「經典」ARM Linux內核與Android-Linux之間有什麼明顯區別嗎?

+0

你剛試過運行'./sopclient'嗎?它看起來像你試圖用'sh'運行它,它會嘗試將該文件解釋爲shell腳本(因此是錯誤)。 – mdm 2012-07-08 14:23:24

+0

以'。/ sopclient'運行* -bash:./sopclient:沒有這樣的文件或目錄*。但sopclient位於當前目錄並且是可執行文件 – ov1d1u 2012-07-08 14:26:29

+0

除了系統庫問題(您可能可以使用/ system/lib中的android庫和/ system/bin中的鏈接程序修復),該程序不太可能除非它是傳入和傳出接口是可以複製的接口。在傳入方面,你可能有標準的網絡API,但是除非它將結果轉儲到標準輸出或文件,否則輸出端將會很有挑戰性。 – 2012-07-08 15:07:23

回答

12

請注意,可能會依賴於Android的bionic庫,這可能不會出現在另一個Linux ARM上?

您可以檢查通過運行readelf -Ss binary_name看到符號如果有的話,

例如,使用readelf -Ss logwrapper

Symbol table '.dynsym' contains 47 entries: 
    Num: Value Size Type Bind Vis  Ndx Name 
    0: 00000000  0 NOTYPE LOCAL DEFAULT UND 
    1: 00000000  0 FUNC GLOBAL DEFAULT UND __aeabi_unwind_cpp_pr0 
    2: 00000000  0 FUNC GLOBAL DEFAULT UND strlen 
    3: 00000000  0 FUNC GLOBAL DEFAULT UND __errno 
    4: 00000000  0 FUNC GLOBAL DEFAULT UND open 
    5: 00000000  0 FUNC GLOBAL DEFAULT UND close 
    6: 00000000  0 FUNC GLOBAL DEFAULT UND __stack_chk_fail 
    7: 00000000  0 OBJECT GLOBAL DEFAULT UND __stack_chk_guard 
    8: 00000000  0 FUNC GLOBAL DEFAULT UND pthread_mutex_unlock 
    9: 00000000  0 FUNC GLOBAL DEFAULT UND pthread_mutex_lock 
    10: 00000000  0 FUNC GLOBAL DEFAULT UND read 
    11: 00000000  0 FUNC GLOBAL DEFAULT UND abort 
    12: 00000000  0 OBJECT GLOBAL DEFAULT UND __sF 
    13: 00000000  0 FUNC GLOBAL DEFAULT UND memcpy 
    14: 00000000  0 FUNC GLOBAL DEFAULT UND __libc_init 
    15: 00000000  0 FUNC GLOBAL DEFAULT UND exit 
    16: 0000a170  0 NOTYPE GLOBAL DEFAULT 19 __dso_handle 
    17: 0000a008  0 NOTYPE GLOBAL DEFAULT 13 __INIT_ARRAY__ 
    18: 0000a010  0 NOTYPE GLOBAL DEFAULT 14 __FINI_ARRAY__ 
    19: 00000000  0 FUNC GLOBAL DEFAULT UND setgid 
    20: 00000000  0 FUNC GLOBAL DEFAULT UND writev 
    21: 00000000  0 FUNC GLOBAL DEFAULT UND dup2 
    22: 00000000  0 FUNC GLOBAL DEFAULT UND access 
    23: 00000000  0 FUNC GLOBAL DEFAULT UND __aeabi_unwind_cpp_pr1 
    24: 00000000  0 FUNC GLOBAL DEFAULT UND memmove 
    25: 00000000  0 FUNC GLOBAL DEFAULT UND fork 
    26: 00000000  0 FUNC GLOBAL DEFAULT UND execvp 
    27: 00000000  0 FUNC GLOBAL DEFAULT UND strncmp 
    28: 00000000  0 FUNC GLOBAL DEFAULT UND strcmp 
    29: 00000000  0 FUNC GLOBAL DEFAULT UND ptsname 
    30: 00000000  0 FUNC GLOBAL DEFAULT UND setuid 
    31: 00000000  0 FUNC GLOBAL DEFAULT UND strerror 
    32: 00000000  0 FUNC GLOBAL DEFAULT UND vsnprintf 
    33: 00000000  0 FUNC GLOBAL DEFAULT UND unlockpt 
    34: 00000000  0 FUNC GLOBAL DEFAULT UND wait 
    35: 00000000  0 FUNC GLOBAL DEFAULT UND fputs 
    36: 00009318  0 NOTYPE GLOBAL DEFAULT ABS __exidx_start 
    37: 00009368  0 NOTYPE GLOBAL DEFAULT ABS __exidx_end 
    38: 0000a15c  0 NOTYPE GLOBAL DEFAULT 18 __data_start 
    39: 0000a170  0 NOTYPE GLOBAL DEFAULT ABS _edata 
    40: 0000a170  0 NOTYPE GLOBAL DEFAULT ABS __bss_start 
    41: 0000a170  0 NOTYPE GLOBAL DEFAULT ABS __bss_start__ 
    42: 0000a188  0 NOTYPE GLOBAL DEFAULT ABS _bss_end__ 
    43: 0000a188  0 NOTYPE GLOBAL DEFAULT ABS __bss_end__ 
    44: 0000a188  0 NOTYPE GLOBAL DEFAULT ABS __end__ 
    45: 0000a188  0 NOTYPE GLOBAL DEFAULT ABS _end 
    46: 00080000  0 NOTYPE GLOBAL DEFAULT ABS _stack 

公告中使用的符號,就是暗示你檢查符號,最後問題對此,readelf -d logwrapper

Dynamic section at offset 0x2020 contains 24 entries: 
    Tag  Type       Name/Value 
0x00000003 (PLTGOT)      0xa0e8 
0x00000002 (PLTRELSZ)     208 (bytes) 
0x00000017 (JMPREL)      0x875c 
0x00000014 (PLTREL)      REL 
0x00000011 (REL)      0x882c 
0x00000012 (RELSZ)      16 (bytes) 
0x00000013 (RELENT)      8 (bytes) 
0x00000015 (DEBUG)      0x0 
0x00000006 (SYMTAB)      0x8280 
0x0000000b (SYMENT)      16 (bytes) 
0x00000005 (STRTAB)      0x8570 
0x0000000a (STRSZ)      490 (bytes) 
0x00000004 (HASH)      0x8128 
0x00000001 (NEEDED)      Shared library: [libc.so] 
0x00000001 (NEEDED)      Shared library: [libstdc++.so] 
0x00000001 (NEEDED)      Shared library: [libm.so] 
0x00000020 (PREINIT_ARRAY)    0xa000 
0x00000021 (PREINIT_ARRAYSZ)   0x8 
0x00000019 (INIT_ARRAY)     0xa008 
0x0000001b (INIT_ARRAYSZ)    8 (bytes) 
0x0000001a (FINI_ARRAY)     0xa010 
0x0000001c (FINI_ARRAYSZ)    8 (bytes) 
0x0000001e (FLAGS)      
0x00000000 (NULL)      0x0 

有三個庫在運行時動態鏈接中,事情是, bionic圖書館是從本機C和Android的角度來看libc.so,所以仔細檢查一下!

還有其他的ARM libc.so將會以ucLibC爲幌子,所以里程可能會有所不同。唯一的方法就是在Linux ARM下運行它,看看會發生什麼,如果它發生了分割錯誤或總線錯誤,那麼你就會知道。