我尝试为STM32编译一个简单的汇编程序,以检查GCC是否正常工作:
.syntax unified
.cpu cortex-m3
.thumb
.word 0x20000400
.word 0x080000ed
.space 0xe4
nop
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb main.s
编译器生成以下消息:
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/lib/thumb/v7-m/nofp/crt0.o: in function `_mainCRTStartup':
/build/newlib-pB30de/newlib-3.3.0/build/arm-none-eabi/thumb/v7-m/nofp/libgloss/arm/semihv2m/../../../../../../../../libgloss/arm/crt0.S:545: undefined reference to `main'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/lib/thumb/v7-m/nofp/libc.a(lib_a-exit.o): in function `exit':
/build/newlib-pB30de/newlib-3.3.0/build/arm-none-eabi/thumb/v7-m/nofp/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
collect2: error: ld returned 1 exit status
我无法识别发生的问题,即使在做了一些研究之后。我了解编译器的基本原理,但我不精通使用GCC。
1条答案
按热度按时间vnzz0bqm1#
如果您的目标只是验证gcc是否正常工作,那么您可以使用以下命令构建一个可执行文件-您的程序被稍微修改了一下,以便它有一个入口点(Reset_Handler),
.space 0xe4
现在是.space 0xf8
,这样代码就可以在4字节的边界上对齐。我决定程序从0x00080100
开始,但根据目标上中断向量的数量,这可能是一个不同的值。编译/链接:
转储内存内容/反汇编:
理想情况下,您现在需要: