Compiling to ARM I get "Error: attempt to use an ARM instruction on a Thumb-only processor"
Compiling to ARM I get "Error: attempt to use an ARM instruction on a Thumb-only processor"
以下命令
/usr/bin/arm-linux-gnueabihf-gcc -O3 -DNDEBUG -march=armv7-a -mfloat-abi=hard -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -fno-function-sections -fno-lto -g -Wno-variadic-macros -Wno-non-virtual-dtor -o testAsm.S.o -c testAsm.S
在下面的汇编文件中 testAsm.S
:
.syntax unified
.arch armv7
.fpu vfpv3
.code 32
.global _functionPointer
.p2align 2
.global _asmFunction
.type _asmFunction, %function
_asmFunction:
PUSH {r1-r3,lr}
VPUSH {d0-d7}
MOVW r1,#:lower16:_functionPointer
MOVT r1,#:upper16:_functionPointer
LDR r2, [r1]
CMP r2, #0
BEQ asmFunction_restore
MOV r1, #0
BLX r2
asmFunction_restore:
VPOP {d0-d7}
POP {r1-r3,pc}
为每条指令产生以下错误
Error: attempt to use an ARM instruction on a Thumb-only processor
具体来说,下面是输出:
testAsm.S: Assembler messages:
testAsm.S:10: Error: attempt to use an ARM instruction on a Thumb-only processor -- `push {r1-r3,lr}'
testAsm.S:11: Error: attempt to use an ARM instruction on a Thumb-only processor -- `vpush {d0-d7}'
testAsm.S:12: Error: attempt to use an ARM instruction on a Thumb-only processor -- `movw r1,#:lower16:_functionPointer'
testAsm.S:13: Error: attempt to use an ARM instruction on a Thumb-only processor -- `movt r1,#:upper16:_functionPointer'
testAsm.S:14: Error: attempt to use an ARM instruction on a Thumb-only processor -- `ldr r2,[r1]'
testAsm.S:15: Error: attempt to use an ARM instruction on a Thumb-only processor -- `cmp r2,#0'
testAsm.S:16: Error: attempt to use an ARM instruction on a Thumb-only processor -- `beq asmFunction_restore'
testAsm.S:17: Error: attempt to use an ARM instruction on a Thumb-only processor -- `mov r1,#0'
testAsm.S:18: Error: attempt to use an ARM instruction on a Thumb-only processor -- `blx r2'
testAsm.S:20: Error: attempt to use an ARM instruction on a Thumb-only processor -- `vpop {d0-d7}'
testAsm.S:21: Error: attempt to use an ARM instruction on a Thumb-only processor -- `pop {r1-r3,pc}'
我尝试为 ARM 进行编译。为什么说 Thumb-only 模式?
编辑:显然,将程序集文件从 .arch armv7
更改为 .arch armv7a
可以解决问题。
GNU 的 arch=armv7
可能令人困惑,它代表了 ARMv7-A 和 ARMv7-M 的 交集(使其具有可疑的实用性)。因此将它与 .code 32
组合(相当于 -marm
命令行选项),它告诉 assembler 到 assemble 到 ARM 编码,而 ARMv7-M 不会支持,让它无法 assemble 任何东西。
当然,简单地停止并在指令或选项处引发错误使其处于不可能的情况对于 GAS 来说太明智了,所以它继续前进并且失败 assemble 每条指令单独...
以下命令
/usr/bin/arm-linux-gnueabihf-gcc -O3 -DNDEBUG -march=armv7-a -mfloat-abi=hard -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -fno-function-sections -fno-lto -g -Wno-variadic-macros -Wno-non-virtual-dtor -o testAsm.S.o -c testAsm.S
在下面的汇编文件中 testAsm.S
:
.syntax unified
.arch armv7
.fpu vfpv3
.code 32
.global _functionPointer
.p2align 2
.global _asmFunction
.type _asmFunction, %function
_asmFunction:
PUSH {r1-r3,lr}
VPUSH {d0-d7}
MOVW r1,#:lower16:_functionPointer
MOVT r1,#:upper16:_functionPointer
LDR r2, [r1]
CMP r2, #0
BEQ asmFunction_restore
MOV r1, #0
BLX r2
asmFunction_restore:
VPOP {d0-d7}
POP {r1-r3,pc}
为每条指令产生以下错误
Error: attempt to use an ARM instruction on a Thumb-only processor
具体来说,下面是输出:
testAsm.S: Assembler messages:
testAsm.S:10: Error: attempt to use an ARM instruction on a Thumb-only processor -- `push {r1-r3,lr}'
testAsm.S:11: Error: attempt to use an ARM instruction on a Thumb-only processor -- `vpush {d0-d7}'
testAsm.S:12: Error: attempt to use an ARM instruction on a Thumb-only processor -- `movw r1,#:lower16:_functionPointer'
testAsm.S:13: Error: attempt to use an ARM instruction on a Thumb-only processor -- `movt r1,#:upper16:_functionPointer'
testAsm.S:14: Error: attempt to use an ARM instruction on a Thumb-only processor -- `ldr r2,[r1]'
testAsm.S:15: Error: attempt to use an ARM instruction on a Thumb-only processor -- `cmp r2,#0'
testAsm.S:16: Error: attempt to use an ARM instruction on a Thumb-only processor -- `beq asmFunction_restore'
testAsm.S:17: Error: attempt to use an ARM instruction on a Thumb-only processor -- `mov r1,#0'
testAsm.S:18: Error: attempt to use an ARM instruction on a Thumb-only processor -- `blx r2'
testAsm.S:20: Error: attempt to use an ARM instruction on a Thumb-only processor -- `vpop {d0-d7}'
testAsm.S:21: Error: attempt to use an ARM instruction on a Thumb-only processor -- `pop {r1-r3,pc}'
我尝试为 ARM 进行编译。为什么说 Thumb-only 模式?
编辑:显然,将程序集文件从 .arch armv7
更改为 .arch armv7a
可以解决问题。
GNU 的 arch=armv7
可能令人困惑,它代表了 ARMv7-A 和 ARMv7-M 的 交集(使其具有可疑的实用性)。因此将它与 .code 32
组合(相当于 -marm
命令行选项),它告诉 assembler 到 assemble 到 ARM 编码,而 ARMv7-M 不会支持,让它无法 assemble 任何东西。
当然,简单地停止并在指令或选项处引发错误使其处于不可能的情况对于 GAS 来说太明智了,所以它继续前进并且失败 assemble 每条指令单独...