Linux 启动qt 非法指令,交叉编译Qt 4.7时的“非法指令”

我现在已经在这个问题上挣扎了一个多星期了,仍然无法找到解决方案……

我正在尝试为ARM设备交叉编译Qt 4.7嵌入式开源版本.构建过程本身完成没有问题,但生成的二进制文件似乎包含处理器不理解的指令.

>在i386上构建主机是Debian 5(Etch)(在虚拟PC上运行)

>该设备是带有ARM处理器的Trimble Nomad手持设备(see full cpuinfo和kernel configuration)

>我使用为设备制作的原始构建工具链,并且到目前为止工作正常(甚至可以成功构建Gnash) – 请参阅compiler settings and version

>我正在使用基于linux-arm-gnueabi-g的自定义qmake.conf并适应使用正确的工具链 – see source code here

>我通过向编译器标志添加-msoft-float -D__GCC_FLOAT_NOT_NEEDED进行了部分改进,但在某些情况下仍然会出现“非法指令”错误(但至少这是一个很大的改进)

>二进制文件本身基本上可以工作,但在某些情况下,程序会因“非法指令”错误而崩溃.我相信这在某些浮点运算期间发生在进行图形处理时.

>添加-mcpu = xscale,-march = armv4,-O0,-march = armv4,-mtune = arm920t(并非所有在同一时间)都没有任何帮助.

>使用–debug标志构建Qt似乎可以解决所有问题,但添加-O2标志会重新引入它们.奇怪的是没有–debug的-O0设置没有帮助.

>可以看到编译器配置和输出输出here.有很多对齐警告但是they are said to be false warnings of the compiler.

> Qt 4.7.2肯定会有一些变化,因为早期版本(4.7.1,4.7.0)运行正常.

配置设置:

./configure \

-embedded arm \

-xplatform qws/linux-arm-angstrom-gnueabi-g++ \

-debug \

-no-largefile \

-no-multimedia \

-no-audio-backend \

-no-phonon \

-no-phonon-backend \

-webkit \

-javascript-jit \

-no-xshape \

-no-xvideo \

-no-xsync \

-no-xinerama \

-no-xcursor \

-no-xfixes \

-no-xrandr \

-no-xrender \

-no-xinput \

-no-xkb \

-no-opengl \

-nomake docs \

-nomake examples \

-nomake tools \

-nomake demos \

-nomake translations \

-opensource \

-qt-mouse-tslib \

-qt-libjpeg \

-qt-gif

坠机前的strace:

$LD_LIBRARY_PATH=. QT_QWS_FONTDIR=$PWD/fonts QT_PLUGIN_PATH=$PWD/plugins QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0 strace ./digitalclock -qws test.htm

...

lseek(15, 0, SEEK_END) = 16998

write(15, "\t\n\f\0\367\t", 6) = 6

write(15, "\0\0+\234\325\343\306{\3\0\0\0\0J\370\377\351\301\336\377"..., 120) = 120

lseek(15, 0, SEEK_END) = 17124

write(15, "\10\10\10\0\371\10", 6) = 6

write(15, "\0\6j\251\260\201\27\0\2\276\377\351\334\377\346\32K\377"..., 64) = 64

lseek(15, 0, SEEK_END) = 17194

write(15, "\7\10\10\0\371\7", 6) = 6

write(15, "\0\4c\245\263\224 \0\1\271\377\367\315\356P\0I\377\364"..., 64) = 64

lseek(15, 0, SEEK_END) = 17264

write(15, "\10\n\10\1\366\10", 6) = 6

write(15, "\37 \3\0\0\0\0\0\374\377\34\0\0\0\0\0\374\377\34\0\0\0"..., 80) = 80

fcntl64(15, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0

lseek(15, 0, SEEK_END) = 17350

mremap(0x415f5000, 16552, 17350, MREMAP_MAYMOVE) = 0x415f5000

--- SIGILL (Illegal instruction) @ 0 (0) ---

rt_sigaction(SIGILL, {SIG_DFL}, {0x401b7d34, [ILL], SA_RESTART|0x4000000}, 8) = 0

socket_subcall(0x1f8004, 0, 0x100, 0, 0, 0x18844, 0x18840, 0x12c) = 0

ioctl(12, KDSKBMODE, 0x2) = 0

ioctl(12, SNDCTL_TMR_START or TCSETS, {B38400 -opost -isig -icanon -echo ...}) = 0

close(12) = 0

ioctl(10, KDSETMODE, 0x1) = 0

write(10, "\33[9;15]\33[?33h\33[?25h\33[?0c\0", 25) = 25

close(10) = 0

statfs64(umovestr: Input/output error

0x6d4f, 27983, {???}) = 0

sigreturn() = ? (mask now [ILL ABRT BUS FPE USR1 SEGV USR2 PIPE STKFLT CHLD CONT STOP TTOU URG XCPU VTALRM PROF WINCH IO PWR RTMIN])

--- SIGILL (Illegal instruction) @ 0 (0) ---

+++ killed by SIGILL +++

Process 27983 detached

崩溃的gdb回溯(由于使用调试信息进行编译,我缺少调试符号)解决了这个问题:

(gdb) run -qws

Starting program: /home/.qt-test2/digitalclock -qws

Program received signal SIGILL, Illegal instruction.

0x4130268c in __sigsetjmp () from /lib/libc.so.6

(gdb) bt

#0 0x4130268c in __sigsetjmp () from /lib/libc.so.6

#1 0x4046ee5c in ?? () from ./libQtGui.so.4

(gdb)

请注意,该设备预装了Qtopia 4.3,供应商也无法解释我的构建问题.

更新

在Igor Skochinsky的帮助下,我可以找到导致SIGILL的确切汇编指令.由于某种原因,指令在导致错误之前正常工作47次.请参阅下面的gdb输出(注意我根本不熟悉ARM汇编程序):

$LD_LIBRARY_PATH=. QT_QWS_FONTDIR=$PWD/fonts QT_PLUGIN_PATH=$PWD/plugins QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0 gdb ./digitalclock

GNU gdb 6.6

Copyright (C) 2006 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB. Type "show warranty" for details.

This GDB was configured as "arm-angstrom-linux-gnueabi"...

Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) start -qws

Breakpoint 1 at 0xaa58: file main.cpp, line 47.

Starting program: /home/.qt-test2/digitalclock -qws

[Thread debugging using libthread_db enabled]

[New Thread 1073870720 (LWP 2799)]

[Switching to Thread 1073870720 (LWP 2799)]

main (argc=2, argv=0xbea17d04) at main.cpp:47

47 main.cpp: No such file or directory.

in main.cpp

(gdb) display/i $pc

1: x/i $pc 0xaa58 : sub r3, r11, #28 ; 0x1c

(gdb) display/x $r2

2: /x $r2 = 0xbea17d10

(gdb) display/x $f2

3: /x $f2 = 0x0

(gdb) b *0x41302684

Breakpoint 2 at 0x41302684

(gdb) continue

Continuing.

---> no problem here:

Breakpoint 2, 0x41302684 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302684 <__sigsetjmp>: beq 0x413026a0

(gdb) si

0x41302688 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302688 <__sigsetjmp>: stfp f2, [r12], #8

(gdb) si

0x4130268c in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x4130268c <__sigsetjmp>: stfp f3, [r12], #8

(gdb) si

0x41302690 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302690 <__sigsetjmp>: stfp f4, [r12], #8

(gdb) continue

Continuing.

Breakpoint 2, 0x41302684 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302684 <__sigsetjmp>: beq 0x413026a0

(gdb) continue 46

Will ignore next 45 crossings of breakpoint 2. Continuing.

---> __sigsetjmp still working fine, but then:

Breakpoint 2, 0x41302684 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302684 <__sigsetjmp>: beq 0x413026a0

(gdb) si

0x41302688 in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x41302688 <__sigsetjmp>: stfp f2, [r12], #8

(gdb) si

Program received signal SIGILL, Illegal instruction.

0x4130268c in __sigsetjmp () from /lib/libc.so.6

3: /x $f2 = 0x0

2: /x $r2 = 0x293

1: x/i $pc 0x4130268c <__sigsetjmp>: stfp f3, [r12], #8

有什么建议我接下来可以尝试吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值