首页 > 解决方案 > 所有的 ARM 都是平等的吗?

问题描述

我有一个来自旧硬件的工具链(来自 Moxa 的 W315),当我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, ARM, EABI5 version 1 (SYSV), dynamically linked, 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

标签: armembeddedlibraries

解决方案


不,他们不是。但是您可以使用以下过程为您的平台构建一个最新/受支持/安全的 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

推荐阅读