裸机交叉编译器输入 [英] Bare metal cross compilers input

查看:94
本文介绍了裸机交叉编译器输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

裸机交叉编译器的输入限制是什么...因为它不编译带有指针或mallocs的程序...或任何需要比底层硬件更多的内容....如何可以找到这些限制..

What are the input limitations of a bare metal cross compiler...as in does it not compile programs with pointers or mallocs......or anything that would require more than the underlying hardware....also how can 1 find these limitations..

我还想问...我为目标mips构建了一个交叉编译器..我需要使用此交叉编译器创建mips可执行文件...但是我找不到可执行文件的位置...因为里面有1个可执行文件,我发现mipsel-linux-cpp应该可以编译,组装和链接,然后生成a.out,但它没有这样做...

I also wanted to ask...I built a cross compiler for target mips..i need to create a mips executable using this cross compiler...but i am not able to find where the executable is...as in there is 1 executable which i found mipsel-linux-cpp which is supposed to compile,assemble and link and then produce a.out but it is not doing so...

但是./cc1提供了mips程序集....

However the ./cc1 gives a mips assembly.......

有一个安装文件夹,其中包含一个gcc可执行文件,该文件使用i386程序集,然后给出一个exe ...我不明白当我将目标指定为mips时,gcc exe如何给i386而不提供mips程序集.

There is an install folder which has a gcc executable which uses i386 assembly and then gives an exe...i dont understand how can the gcc exe give i386 and not mips assembly when i have specified target as mips....

请帮助我真的无法理解什么是幸福...

please help im really not able to understand what is happ...

我遵循了以下步骤. 1.安装了binutils 2.19 2.为mips配置了gcc...(g ++,core)

I followed the foll steps.. 1. Installed binutils 2.19 2. configured gcc for mips..(g++,core)

推荐答案

我建议您应该提出两个单独的问题.

I would suggest that you should have started two separate questions.

GNU工具链没有任何OS依赖性,但GNU库却有.大多数GCC的裸机交叉构建都使用Newlib C库,该库提供了一组 syscall 存根,您必须自己将它们映射到目标.这些存根包括实现流I/O和堆管理所必需的低级调用.根据您的需要,它们可以非常简单也可以非常复杂.如果唯一的I/O支持是到UART的stdin/stdout/stderr,那么这很简单.您不必实现所有内容,但是如果您不实现I/O存根,则将无法使用例如printf().如果要使malloc()工作,必须实现sbrk()/sbrk_r()系统调用.

The GNU toolchain does not have any OS dependencies, but the GNU library does. Most bare-metal cross builds of GCC use the Newlib C library which provides a set of syscall stubs that you must map to your target yourself. These stubs include low-level calls necessary to implement stream I/O and heap management. They can be very simple or very complex depending on your needs. If the only I/O support is to a UART to stdin/stdout/stderr, then it is simple. You don't have to implement everything, but if you do not implement teh I/O stubs, you won't be able to use printf() for example. You must implement the sbrk()/sbrk_r() syscall is you want malloc() to work.

GNU C ++库将与Newlib作为其基础库一起正常使用.如果使用C ++,则C运行时启动程序(通常为crt0.s)必须包含静态初始化程序循环,以调用代码可能包含的任何静态对象的构造函数.当然,运行时启动还必须初始化处理器,时钟,SDRAM控制器,计时器,MMU等.那是你的责任,而不是编译器的责任.

The GNU C++ library will work correctly with Newlib as its underlying library. If you use C++, the C runtime start-up (usually crt0.s) must include the static initialiser loop to invoke the constructors of any static objects that your code may include. The run-time start-up must also of course initialise the processor, clocks, SDRAM controller, timers, MMU etc; that is your responsibility, not the compiler's.

我没有MIPS目标的经验,但是所有处理器的原理都是相同的,有一篇非常有用的文章,名为,您可能会发现它很有帮助,其中的大部分内容都是有意义的-尤其是移植了有关实现Newlib存根的部分.

I have no experience of MIPS targets, but the principles are the same for all processors, there is a very useful article called "Building Bare Metal ARM with GNU" which you may find helpful, much of it will be relevant - especially porting the parts regarding implementing Newlib stubs.

关于另一个问题,如果您的编译器名为mipsel-linux-cpp,则它不是裸机"构建,而是Linux构建.同样,该可执行文件并不是真正的编译,汇编和链接",而是单独调用预处理器,编译器,汇编器和链接器的驱动程序.必须正确配置它才能调用跨工具而不是宿主工具.我通常分别调用链接器,以执行有关链接哪个标准库(-nostdlib)的决定,并且还因为当应用程序由多个执行单元组成时,它更有意义.除了这里提供的帮助之外,我无法提供太多帮助,因为我一直使用明显比我耐心得多的人构建的GNU-ARM工具,而且将其托管在Windows上,而在这种情况下,调用宿主工具链的可能性较小(一个我也避免了那些依赖Cygwin的工具链的原因)

Regarding your other question, if your compiler is called mipsel-linux-cpp, then it is not a 'bare-metal' build but rather a Linux build. Also this executable does not really "compile, assemble and link", it is rather a driver that separately calls the pre-processor, compiler, assembler and linker. It has to be configured correctly to invoke the cross-tools rather than the host tools. I generally invoke the linker separately in order to enforce decisions about which standard library to link (-nostdlib), and also because it makes more sense when a application is comprised of multiple execution units. I cannot offer much help other than that here since I have always used GNU-ARM tools built by people with obviously more patience than me, and moreover hosted on Windows, where there is less possibility of the host tool-chain being invoked instead (one reason why I have also avoided those tool-chains that rely on Cygwin)

这篇关于裸机交叉编译器输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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