所有 ARM 都生而平等吗?

问题描述

我有一个来自旧硬件 (W315 from Moxa) 的工具链,当我对其库文件运行 file 时,我得到了这个:

[bf@localhost arm-linux-gnueabi]$ file /usr/local/arm-linux/lib/libssl.so.0.9.8 
/usr/local/arm-linux/lib/libssl.so.0.9.8: ELF 32-bit LSB shared object,ARM,version 1 (ARM),dynamically linked,not stripped

如您所见,这个 OpenSSL 库已经很老了,不支持 TLSv1.2,而我(至少)需要它。所以我试图找到一个新版本库的 ARM 二进制文件。我从 Debian 找到了 1.0.0,但它的签名有点不同:

[bf@localhost arm-linux-gnueabi]$ file libssl.so.1.0.0 
libssl.so.1.0.0: ELF 32-bit LSB shared object,EABI5 version 1 (SYSV),BuildID[sha1]=83c83f5d3da36759c7adc837405b28539569d26e,stripped

它们都是 32 位和 ELF,但我不确定“ARM”部分是否具有可比性。

我可以在我的应用程序中使用那个 1.0.0 库吗?如果没有,我应该寻找什么来搜索正确的二进制文件

来自 cat /proc/cpuinfo 的结果:

root@Moxa:/home/fabs# cat /proc/cpuinfo
Processor   : ARM922Tid(wb) rev 1 (v4l)
BogoMIPS    : 76.59
Features    : swp half thumb 
cpu implementer : 0x66
cpu architecture: 4
cpu variant : 0x0
cpu part    : 0x526
cpu revision    : 1
Cache type  : VIVT write-back
Cache clean : cp15 c7 ops
Cache lockdown  : format B
Cache format    : Harvard
I size      : 16384
I assoc     : 2
I line length   : 16
I sets      : 512
D size      : 16384
D assoc     : 2
D line length   : 16
D sets      : 512

Hardware    : Moxa cpu development platform
Revision    : 0000
Serial      : 0000000000000000

解决方法

不,他们不是。但是您可以使用以下过程为您的平台构建最新/支持/安全的 openssl 版本:

# openssl
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar zxf openssl-1.1.1k.tar.gz

# a toolchain I know is working for arm922t according to gcc documentation
wget "https://releases.linaro.org/components/toolchain/binaries/latest-6/arm-linux-gnueabi/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabi.tar.xz" -O gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabi.tar.xz
mkdir -p /opt/arm/6
tar Jxf gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabi.tar.xz -C /opt/arm/6

# building
cd openssl-1.1.1k
./Configure linux-generic32 --cross-compile-prefix=/opt/arm/6/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi- --prefix=/opt/openssl-1.1.1k --openssldir=/opt/openssl-1.1.1k

编辑Makefile,并替换

CFLAGS=-Wall -O3

作者:

CFLAGS=-Wall -O3 -march=armv4t -mcpu=arm922t

那么:

make install

ls -gG /opt/openssl-1.1.1k/bin/
    total 576
-rwxr-xr-x 1   6214 Jun 30 12:53 c_rehash
-rwxr-xr-x 1 579740 Jun 30 12:53 openssl

ls -gG /opt/openssl-1.1.1k/lib
    total 6432
drwxr-xr-x 2    4096 Jun 30 12:53 engines-1.1
-rw-r--r-- 1 3312034 Jun 30 12:53 libcrypto.a
lrwxrwxrwx 1      16 Jun 30 12:53 libcrypto.so -> libcrypto.so.1.1
-rwxr-xr-x 1 2152072 Jun 30 12:53 libcrypto.so.1.1
-rw-r--r-- 1  603100 Jun 30 12:53 libssl.a
lrwxrwxrwx 1      13 Jun 30 12:53 libssl.so -> libssl.so.1.1
-rwxr-xr-x 1  502704 Jun 30 12:53 libssl.so.1

file /opt/openssl-1.1.1k/bin/openssl
/opt/openssl-1.1.1k/bin/openssl: ELF 32-bit LSB executable,ARM,EABI5 version 1 (SYSV),dynamically linked,interpreter /lib/ld-linux.so.3,for GNU/Linux 2.6.32,BuildID[sha1]=7b0e69c478f4c7390d416247f95ac60d9a632bd8,with debug_info,not stripped

如果需要,您可以通过在配置命令的末尾添加 -static 选项来构建静态版本:

./Configure linux-generic32 --cross-compile-prefix=/opt/arm/6/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi- --prefix=/opt/openssl-1.1.1k --openssldir=/opt/openssl-1.1.1k -static