如何从我的裸机手臂编译中排除 libc?

发布于 2025-01-15 10:17:53 字数 721 浏览 4 评论 0原文

我正在尝试编译我的第一个针对 ARM Cortex-M0+ MCU 的裸机项目。我正在使用 gcc arm-none-eabi 进行编译。该系统当前由以下部分组成:

  • boot.s——一个包含中断处理程序和中断处理程序的汇编文件。向量表。调用 SystemInit(),然后调用 __main()
  • 的 ac 文件
  • system.c -- 包含芯片初始化代码 SystemInit()__main() main.c -- ac 文件,用于闪烁一些 gpio 引脚
  • cortexm0p.ld -- 用于绝对定位代码和代码的链接器脚本入口点

c 文件使用以下标志进行编译:-mcpu=cortex-m0 -mthumb -nostartfiles -nostdlib -nodefaultlibs -ffreestand -lnosys 然后将目标文件与 arm-none-eabi-ld boot.o system.o main.o -T cortexm0p.ld -o shake.elf 链接在一起,

这会导致错误:arm-none-eabi-ld: 找不到 libc.a

为什么我的链接器命令要查找 libc? / 我需要改变什么才能让它停止?

I am trying to compile my first bare metal project targeting an arm cortex-M0+ MCU. I am compiling with gcc arm-none-eabi. The system currently consists of:

  • boot.s -- an assembly file containing interrupt handlers & vector table. calls SystemInit() then __main()
  • system.c -- a c file containing chip initialization code SystemInit() and __main()
  • main.c -- a c file which blinks some gpio pins
  • cortexm0p.ld -- a linker script for absolute positioning of code & entry point

The c files are compiled with the flags: -mcpu=cortex-m0 -mthumb -nostartfiles -nostdlib -nodefaultlibs -ffreestanding -lnosys
the object files are then linked together with arm-none-eabi-ld boot.o system.o main.o -T cortexm0p.ld -o blink.elf

This results in an error:arm-none-eabi-ld: cannot find libc.a

Why is my linker command looking for libc? / What do I need to change to make it stop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木槿暧夏七纪年 2025-01-22 10:17:53

在这种情况下,我的链接器脚本文件有一个显式的丢弃部分,不包括 libc、libgcc 和 libm。 ::捂脸::

in this case, my linker script file had an explicit discard section excluding libc, libgcc and libm. ::facepalm::

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文