在Thumb-2代码中,不可能在大多数指令中使用寄存器8-15,但这在ARM代码中是可行的。因此,下面的组件提供了一个运行时非法指令错误:编译时寄存器检查Thumb-2代码
.syntax unified
.fpu vfp
.thumb
.text
.globl main
main:
str r12,[sp,#-4] @ r12 is too high, source register is 3 bits wide
但是,我没有得到在编译时警告,即使我用-Wall
:
[email protected]:~/ctests$ arm-linux-gnueabihf-as -Wall -o high.o high.s
ARM GAS high.s page 1
1 .syntax unified
2 .fpu vfp
3 .thumb
4 .text
5 .globl main
6 main:
7 0000 4DF804CC str r12,[sp,#-4]
[email protected]:~/ctests$ arm-linux-gnueabihf-gcc -Wall -o high high.o
[email protected]:~/ctests$ ./high
Illegal instruction
[email protected]:~/ctests$ file high
high: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=c9d90a7d6386bf97a18f9da87a7b2ce422402659, not stripped
是否有任何工具,可以用于在编译时检查非法指令?
谢谢!当我在'main'的末尾添加'bx lr'时,它会起作用。 – Keelan