1

我使用 Gem5 来获取 ARM 处理器的指令访问。我使用 -marm 选项生成代码。

arm-linux-gnueabihf-gcc -static -marm fibcall.c

我相信使用此选项只会生成 32 位 ARM 指令。但结果如下所示:

command line: ./build/ARM/gem5.opt --debug-flags=Exec configs/example/se.py -c tests/test-progs/malardalen/a.out

Global frequency set at 1000000000000 ticks per second
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
      0: system.cpu T0 : @fini+15    :   mov.w   fp, #0           : IntAlu :  D=0x0000000000000000
    500: system.cpu T0 : @_start+3    :   mov.w   lr, #0           : IntAlu :  D=0x0000000000000000
   1000: system.cpu T0 : @_start+7    : ldmstm
   1000: system.cpu T0 : @_start+7.0  :   ldr_uop   r1, [sp, #0]   : MemRead :  D=0x0000000000000001 A=0xbeffff00
   1500: system.cpu T0 : @_start+7.1  :   addi_uop   sp, sp, #4    : IntAlu :  D=0x00000000beffff04
   2000: system.cpu T0 : @_start+9    :   mov   r2, sp             : IntAlu :  D=0x00000000beffff04
   2500: system.cpu T0 : @_start+11    : ldmstm
   2500: system.cpu T0 : @_start+11.0  :   str_uop   r2, [sp, #4]   : MemWrite :  D=0x00000000beffff04 A=0xbeffff00
   3000: system.cpu T0 : @_start+11.1  :   subi_uop   sp, sp, #4    : IntAlu :  D=0x00000000beffff00
   3500: system.cpu T0 : @_start+13    : ldmstm
   3500: system.cpu T0 : @_start+13.0  :   str_uop   r0, [sp, #4]   : MemWrite :  D=0x0000000000000000 A=0xbefffefc
   4000: system.cpu T0 : @_start+13.1  :   subi_uop   sp, sp, #4    : IntAlu :  D=0x00000000befffefc
   4500: system.cpu T0 : @_start+15    :   ldr.w   r12, [pc, #16]   : MemRead :  D=0x0000000000009039 A=0x88d8
   5000: system.cpu T0 : @_start+19    :   str.w   r12, [sp, #-4]!
   5000: system.cpu T0 : @_start+19.0  :   str.w   r12, [sp, #-4]!  : MemWrite :  D=0x0000000000009039 A=0xbefffef8
   5500: system.cpu T0 : @_start+19.1  :   subi_uop.w   sp, sp, #4  : IntAlu :  D=0x00000000befffef8
   6000: system.cpu T0 : @_start+23    :   ldr   r0, [pc, #12]      : MemRead :  D=0x0000000000008a4c A=0x88dc

...

我们可以看到,在 2000 年,使用了 _start+9,即 _start+7 的 2 个字节。所以我认为使用了 16 位指令。为什么会这样?为什么不是32位?

另外,有谁知道 _start+7.0 和 _start+7.1 是什么意思?为什么我有两条不同的指令具有相同的内存地址?

提前致谢。

4

1 回答 1

0

使用-marm确实会使编译器为其编译的代码(即fibcall.c 的内容)生成ARM 指令。但是,该_start符号不是该代码的一部分 - 这是您静态链接的工具链提供的标准库的一部分,并且这些显然包含 Thumb-2 指令。如果你想要一个静态二进制文件,它是 100% 纯 ARM 代码,没有互通,并且没有合适的 sysroot 来编译,那么你需要检查该工具链是否有适当的 multilib 选项来提供 ARM 库而不是Thumb 的,或查找/构建一组合适的替换库。

于 2016-03-29T21:57:44.057 回答