最近交叉编译最新的busybox 1.35源码在OK6410板子上做实验,遇到了些问题,做下总结。
1. gcc-linaro-7.5.0-2019.12-arm-linux-gnueabi 该系列高版本工具链不能用于busybox的交叉编译
虽然能够编译出来,但系统无法运行,直接提示SIGSEGV段错误,每次重编后的错误日志基本如下,可以看出PC和LR都是错误的,已超出实际内核MMU映射范围,其他寄存器也定位不到代码。
[ 2.696508] init: unhandled page fault (11) at 0x0000000c, code 0x817
[ 2.700443] pgd = (ptrval)
[ 2.702998] [0000000c] *pgd=516bd831, *pte=00000000, *ppte=00000000
[ 2.709293] CPU: 0 PID: 1 Comm: init Not tainted 5.10.103-g43566770ca58 #61
[ 2.716247] Hardware name: Samsung S3C64xx (Flattened Device Tree)
[ 2.722404] PC is at 0xb6fad000
[ 2.725506] LR is at 0xb6facb53
[ 2.728592] pc : [<b6fad000>] lr : [<b6facb53>] psr: 00000030
[ 2.734917] sp : be8b4f00 ip : 00000000 fp : 00000000
[ 2.740135] r10: 000275e4 r9 : 00000000 r8 : 00000000
[ 2.745297] r7 : 00000000 r6 : 00000000 r5 : 00000000 r4 : 00000940
[ 2.751830] r3 : 00000000 r2 : 00000000 r1 : 00000000 r0 : be8b4f00
[ 2.758298] Flags: nzcv IRQs on FIQs on Mode USER_32 ISA Thumb Segment user
[ 2.765702] Control: 00c5387d Table: 517b0008 DAC: 00000055
[ 2.771470] CPU: 0 PID: 1 Comm: init Not tainted 5.10.103-g43566770ca58 #61
[ 2.778348] Hardware name: Samsung S3C64xx (Flattened Device Tree)
[ 2.784583] [<c0014474>] (unwind_backtrace) from [<c0012090>] (show_stack+0x10/0x14)
[ 2.792320] [<c0012090>] (show_stack) from [<c0014c18>] (__do_user_fault+0xbc/0xd0)
[ 2.799852] [<c0014c18>] (__do_user_fault) from [<c0014dd8>] (do_page_fault+0x1ac/0x29c)
[ 2.808017] [<c0014dd8>] (do_page_fault) from [<c001502c>] (do_DataAbort+0x38/0xbc)
[ 2.815603] [<c001502c>] (do_DataAbort) from [<c000903c>] (__dabt_usr+0x3c/0x40)
[ 2.822988] Exception stack(0xc0c47fb0 to 0xc0c47ff8)
由于低版本的arm-none-linux-gnueabi-4.8.3交叉工具链是可以正常编译busybox并且运行正常。故一开始的思路是比较4.8.3 与7.5.0工具链的差异 。ELF文件的运行除了本身代码,还跟可能的关联动态库有关。
readelf -h -d <so库或elf文件> 查询关联的so依赖库和ELF格式信息
$ arm-linux-gnueabi-readelf -d rootfs/bin/busybox 查询依赖动态链接段
Dynamic section at offset 0x10900c contains 26 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libresolv.so.2]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000c (INIT) 0xc604
$ arm-linux-gnueabi-readelf -h ~/tools/7.5.0/arm-linux-gnueabi/libc/lib/libc-2.25.so
ELF Header:
Magic: 7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - GNU
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Entry point address: 0x16989
Start of program headers: 52 (bytes into file)
Start of section headers: 13886044 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
...
$ arm-linux-gnueabi-readelf -h ~/tools/4.8.3/arm-none-linu
BusyBox交叉编译问题

本文探讨了使用不同版本的GCC工具链交叉编译BusyBox过程中遇到的问题,特别是GCC 7.5.0版本编译时出现的SIGSEGV段错误及程序崩溃现象,并给出了可能的解决方案。
最低0.47元/天 解锁文章
397

被折叠的 条评论
为什么被折叠?



