在 Linux ARM 上运行适用于 Android 的 ARM 二进制文件 [英] Running ARM binaries for Android on Linux ARM

查看:43
本文介绍了在 Linux ARM 上运行适用于 Android 的 ARM 二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在其他配备 Linux 的 ARM 设备(例如 Raspberry Pi)上运行为 Android 构建的 ARM 二进制文件(而不是 .apk)?我正在尝试将我的一个项目移植到 ARM 上,但我需要使用仅适用于 x86(Windows 和 Linux)和(最近的)Android 设备的闭源二进制文件 (SopCast).

It is possible to run an ARM binary built for Android (not the .apk) on other ARM devices featuring Linux (such is Raspberry Pi)? I'm trying to port one of my projects on ARM but I need to use a closed-source binary (SopCast) which is available only for x86 (Windows and Linux) and (recently) Android devices.

运行 file sopclient 显示 ELF 32 位 LSB 可执行文件,ARM,版本 1 (SYSV),动态链接(使用共享库),剥离,但 shsopclient 说只是无法执行二进制文件(是的,我之前 chmoded +x 它).

Running file sopclient shows ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped but sh sopclient says just cannot execute binary file (yes, I chmoded +x it before).

经典"ARM Linux 内核和 Android-Linux 内核之间有什么明显区别吗?

Is there any noticeable difference between a "classic" ARM Linux kernel and a Android-Linux one?

推荐答案

请注意,可能存在对 Android 的 bionic 库的依赖,而这可能不存在于其他 Linux ARM 上?

Be aware that there could be dependencies on the Android's bionic lib which may not be present on another Linux ARM?

您可以通过运行 readelf -Ss binary_name 来检查是否有符号,

You can check that by running a readelf -Ss binary_name to see the symbols if any,

例如使用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

Notice the symbols used, that's your cue to check the symbols, finally issue this, 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 库是 libc.so 从本机 C 和 Android 的角度来看,所以仔细检查一下第一!

There's three libraries dynamically linked in at run-time, thing is, bionic library is libc.so from the native C and Android perspective, So double check on that first!

还有其他 ARM libc.so 会以 ucLibC 所以里程可能会有所不同.唯一的办法,就是在Linux ARM下运行它看看会发生什么,如果它因分段错误或总线错误而爆炸,你就会知道.

There are other ARM libc.so that will come under the guise of ucLibC so the mileage may vary. Only way to see, is to run it under the Linux ARM to see what happens, if it bombs out with segmentation errors or bus errors, you'll know then.

这篇关于在 Linux ARM 上运行适用于 Android 的 ARM 二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆