【问题标题】:Assembly file(.S) throw errors with GNU ARM toolchain in Eclipse photon汇编文件(.S)在 Eclipse photon 中使用 GNU ARM 工具链引发错误
【发布时间】:2020-10-06 22:30:57
【问题描述】:

将汇编文件从 ARMCC 语法移植到 GNU 语法。编译时抛出错误。

环境:Eclipse photon 中用于 ARM7 的 GNU arm 工具链。 需求:在eclipse中从keil ARMCC移植到GNU arm工具链。

已正确编译和构建。当我添加一个程序集文件 iap_blue.S(attached) 时,遇到编译错误(粘贴在下面)。

//iap_blue.S
            .section .text,"x"
            .balign 4

.globl blue_execute
blue_execute:
        STMFD   SP!,{LR}               // Save Return Address
                ADD     R1,R0,#0x14            // R0 = &IAP.cmd, R1 = &IAP.stat
                ADR     LR,blue_exit           // Return Address
                LDR     R2,=0x7FFFFFF1         // IAP Entry (Thumb Mode)
                BX      R2                     // Execute IAP Command

blue_exit:
                LDMFD   SP!,{LR}               // Restore Return Address
                BX      LR                     // Return
                .end
12:18:38 **** Build of configuration Debug for project LEDblink ****
make all
Building file: ../LPC2468_startup.c
Invoking: GNU ARM Cross C Compiler
arm-none-eabi-gcc -mcpu=arm7tdmi-s -march=armv4t -marm -mthumb-interwork -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -include"E:\EclipseARM\workspace\LEDblink\iap_blue.S" -std=gnu11 -MMD -MP -MF"LPC2468_startup.d" -MT"LPC2468_startup.o" -c -o "LPC2468_startup.o" "../LPC2468_startup.c"
In file included from <command-line>:
E:\EclipseARM\workspace\LEDblink\iap_blue.S:1:13: error: expected identifier or '(' before '.' token
1 | .section .text,"x"
| ^
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:17: error: unknown type name 'ADD'
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^~~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:31: error: stray '#' in program
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:32: error: expected identifier or '(' before numeric constant
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^~~~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:14:17: error: unknown type name 'BX'
14 | BX LR // Return
| ^~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:15:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
15 | .end
| ^
In file included from c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\arm-none-eabi\include\stdint.h:14,
from c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\lib\gcc\arm-none-eabi\9.2.1\include\stdint.h:9,
from ../LPC2468_startup.c:1:
c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\arm-none-eabi\include\sys\_stdint.h:20:9: error: unknown type name '__int8_t'
20 | typedef __int8_t int8_t ;
| ^~~~~~~~
subdir.mk:31: recipe for target 'LPC2468_startup.o' failed
make: *** [LPC2468_startup.o] Error 1

【问题讨论】:

  • 所以使用 c 编译器进行汇编,这应该可以正常工作。其次,您是否阅读了该工具的输出?如果你修复 cmets(不能在 gnu 汇编中使用 //cmets)并将其提供给汇编器(不需要这么长的命令行,最初甚至不需要拱门,因为它会默认为 arm)。

标签: eclipse arm eclipse-photon gnu-arm


【解决方案1】:

谢谢。问题解决了。

我想详细说明我犯了什么错误以及如何解决它。这可能对其他人有帮助。 错误一: 我使用 .s 而不是 .S 作为程序集文件。 错误2: Eclipse 编译器中包含的 .S 文件包含文件作为项目设置的一部分。

解决方案: 检查 C/C++ General --> 将 .S 列为汇编文件的文件类型。我将 .s 更改为 .S ,错误 1 ​​已更正。

即使我遇到了我在此处发布的编译错误。 我不确定我的程序集文件是否存在一些与 eclipse 相关的问题或问题,因为我将它从 ARMCC 语法移植到了 GNU 语法。 我创建了自己的 make 文件并使用命令行构建代码,它成功构建而没有任何错误。这意味着 Eclipse 项目配置存在一些问题。

然后,我意识到您在编译器设置中没有包含汇编文件。如果您已经将其包含在项目中。仅此一项就可以正确识别和组装文件。 这解决了错误2。

谢谢。

【讨论】:

    猜你喜欢
    • 2015-07-01
    • 2015-12-20
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 1970-01-01
    相关资源
    最近更新 更多