【问题标题】:GNU assembler, arm IT block errorGNU 汇编器,arm IT 块错误
【发布时间】:2015-12-20 16:18:50
【问题描述】:

我收到一条错误消息,提示 addeq 应该在 IT 块中。据我所知。

这是代码的一部分,位于https://github.com/Jcfunk/g3_kernel/blob/lp-release/arch/arm/crypto/aesbs-core.S_shipped 的第 455 行

    ite eq              @ Thumb2 thing, sanity check in ARM
    addeq   r6,r6,#0x10
    bne .Ldec_loop

addeq 在 IT 块中吗?

从我用谷歌搜索的内容来看,If-Then 块,这个 IT 块意味着 if EQ then ADDEQ else BNE .Ldec_loop。 我觉得 ADDEQ 在 IT 模块中,但我对手臂组装一无所知。 或者可能是构建标志冲突。

这里是 make 输出,make V=1 zImage-dtb ,可能问题是传递给 AS 的标志之一

scripts/gcc-wrapper.py gcc -Wp,-MD,arch/arm/crypto/.aesbs-core.o.d  -nostdinc -isystem /usr/lib/gcc/arm-linux-gnueabihf/5/include -I/sdcard/build/navelA/arch/arm/include -Iarch/arm/include/generated -Iinclude  -include /sdcard/build/navelA/include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-msm/include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables  -D__LINUX_ARM_ARCH__=7 -mcpu=cortex-a15  -include asm/unified.h -msoft-float -gdwarf-2        -c -o arch/arm/crypto/aesbs-core.o arch/arm/crypto/aesbs-core.S

我正在使用 GNU 汇编器版本 2.25.1 (arm-linux-gnueabihf),使用 BFD 版本 (GNU Binutils for Ubuntu) 2.25.1 gcc (Ubuntu 5.2.1-17ubuntu4) 5.2.1 20150911

这是 LG G3 的 Android 内核的一部分,构建在未交叉编译的 arm 设备上

构建标志 -nostdinc -isystem /usr/lib/gcc/arm-linux-gnueabihf/5/include -I/sdcard/build/navelA/arch/arm/include -Iarch/arm/include/generated -Iinclude -包括 ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-msm/include -Wall -DNDEBUG -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -mcpu=cortex-a15 -mtune=cortex-a15 -mfpu=neon-vfpv4 -marm -ffast-math -fsingle -precision-constant -fgcse-lm -fgcse-sm -fsched-spec-load -fforce-addr -Os -marm -fno-dwarf2-cfi-asm -fstack-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -mcpu=cortex-a15 -msoft-float -Uarm -Wframe-larger-than=1024 -Wno-unused-but-set-variable -fomit-frame-pointer -gdwarf-2 -Wdeclaration -语句后 -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -munaligned-access -fforce-addr -fsingle-precision-constant -mcpu =cortex-a15 -mtune=cortex-a15 -marm -mfpu=neon-vfpv4 -fgcse-las -fpredictive-commoning

【问题讨论】:

  • 自从您发布问题后,这些行似乎已移至 448?无论如何,对我来说,代码看起来是正确的; addeqíte 块内,bne 也是 ite 块的一部分。尝试在第 74 行 .code 32 上方插入 #error "wrong architecture",以检查它是否实际构建为 thumb2。
  • @PacMan-- 你对行号的权利。我链接的文件是旧版本。它是由 perl 脚本制成的。来自 Openssl link 我已更新但未提交。
  • 这应该是对上一个相同问题的编辑,但它仍然没有真正包含所有必要的信息:该命令行的路径在您的计算机以外的任何东西上都不起作用(我猜到了一些替换),我们不知道gcc-wrapper.py 做了什么,那些依赖于内核配置的自动生成的头文件的确切状态是什么,或者你正在使用什么版本的 GCC 以及它是如何配置的(这实际上是其中之一这里的关键因素)。不过,碰巧的是,我今天似乎感到既足够通灵又足够宽容……
  • @Notlikethat 正确,也许应该说它适用于 Android 内核。 android.googlesource.com/kernel/msm/+/android-5.1.1_r0.21/…

标签: assembly arm binutils thumb


【解决方案1】:

这个文件作为正常内核构建(ARM 和 Thumb)的一部分构建得很好,所以这显然是您在 GCC 命令行中伪造它的方式的问题。使用-E 运行它以查看预处理输出,当您在顶部附近看到此片段时,事情会变得非常清楚:

...
# 1 "include/generated/autoconf.h" 1
# 5 "./include/linux/kconfig.h" 2
# 1 "<command-line>" 2
# 1 "./arch/arm/include/asm/unified.h" 1
# 74 "./arch/arm/include/asm/unified.h"
 .macro it, cond
 .endm
 .macro itt, cond
 .endm
 .macro ite, cond
 .endm
...

这些头文件显然是为编译为 ARM 代码而设置的,因此这些宏隐藏了 Thumb it 指令,以利于顽固的旧汇编程序,它们可能会因为非 ARM 指令而窒息(而不是仅仅将它们作为非 ARM 指令忽略)现代统一汇编器应该)。因此,当您的汇编器(显然已被 GCC 告知要发出 Thumb 代码)最终看到没有前面的 it 的条件指令时会变得非常不高兴。

因此,使用您的构建命令,您要么只需要编译为 ARM 代码(传递 -marm 是最简单的方法),要么进一步挖掘 KBuild 并找到必要的东西来定义以使内核头文件相信它们'在 Thumb 模式下重新构建“内核”(可能涉及CONFIG_THUMB2_KERNEL)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-26
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    • 2017-08-25
    • 1970-01-01
    相关资源
    最近更新 更多