编译基本的C档为ARM处理器 [英] Compiling basic C file for the ARM processor

查看:163
本文介绍了编译基本的C档为ARM处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的GCC工具链的Yagarto重新编译。我想编译这个简单的程序来获得为.elf 可执行文件:

I am using the Yagarto recompilation of the GCC toolchain. I am trying to compile this simple program to get an .elf executable:

int main(void)
{
    return(0);
}

当键入命令臂无 - EABI - 海合会的main.c 我得到错误信息

When typing the command arm-none-eabi-gcc main.c I get the error message

C:/ yagarto / bin中/../ lib中/ GCC / ARM-NONE-EABI / 4.6.2 /../../../../臂无 - EABI / lib目录\\的libc.a (lib_a-exit.o):
  在功能上退出:
  C:\\msys\\1.0\\home\\yagarto\
ewlib-build\\arm-none-eabi\
ewlib\\libc\\stdlib/../../../../../newlib-1.19.0/newlib/libc/stdlib/exit.c:65:
  未定义的引用
_exit'collect2:LD返回1退出状态

c:/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): In function exit': C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.19.0/newlib/libc/stdlib/exit.c:65: undefined reference to_exit' collect2: ld returned 1 exit status

我在做什么错了?

推荐答案

Newlib需要你定义一个 _exit 符号。也可能有,你必须提供使newlib工作的其他符号:<一href=\"http://sourceware.org/newlib/libc.html#Stubs\">http://sourceware.org/newlib/libc.html#Stubs

Newlib requires you to define an _exit symbol. There might also be other symbols that you have to provide to make newlib work: http://sourceware.org/newlib/libc.html#Stubs

这样的事情应该是足够了(假设你编译用于微控制器,不这样做,当你有一个OS):

Something like this should be sufficient (assuming you are compiling for a microcontroller, don't do this when you have an OS):

.globl _exit
_exit:
    b     . // Loop until reset

或在C:

void _exit(void) {
    while(1) {
        // Loop until reset
    }
}

BTW:你可能想纺前禁止中断。

BTW: you might want to disable interrupts before spinning.

编辑:也许豆蔻一些额外的信息。 Yagarto包括Newlib为libc的,这是提供像的printf()的malloc()等,但是函数库,它无法知道如何将一个字符发送到屏幕或控制台(printf中的情况下),或者如何退出你叫中止()情况退出()。因此,Newlib要求您提供一些基本功能的实现,取决于你用​​什么Newlib的功能。

Maybe a litte bit extra information. Yagarto includes Newlib as libc, which is a library providing functions like printf(), malloc(), etc. However, it cannot know how to send a character to a screen or console (in case of printf), or how to exit in case you call abort() or exit(). Therefore, Newlib requires you to provide implementations of a few basic function, depending on what functionality of Newlib you use.

这篇关于编译基本的C档为ARM处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆