什么是“nosys"、“nano"、“rdimon"?使用 ARM GCC 时的术语? [英] What are "nosys", "nano", "rdimon" terms when using ARM GCC?
问题描述
我正在学习使用 GCC 工具链编写 ARM 代码.我遇到了一些找不到文档的 GCC 选项.有人可以帮忙解释一下他们是做什么的吗?
I am learning to write ARM code using the GCC toolchain. I've run into a few GCC options that I cannot find documentation for. Could someone please help explain what they do?
-specs=nosys.specs
-specs=nano.specs
-specs=rdimon.specs
-lnosys
-specs=nosys.specs
和 -lnosys
有什么关系?你是一起使用它们,还是它们相互排斥,或者其他什么?
How do -specs=nosys.specs
and -lnosys
relate? Do you use them together, or are they exclusive of each other, or something else?
还有nano,我收集到暗示使用newlib-nano 库.我已经看到它与 -lm
和 -lc
结合使用.这只是给你标准的 libc 和 libm 函数吗?
And nano, I've gathered to imply using the newlib-nano library. I've seen this used in conjunction with -lm
and -lc
. Does this just give you the standard libc and libm functions?
rdimon
代表什么?我知道这是用于半主机",这意味着以某种方式使用主机 IO.这是否意味着我可以打印到主机控制台?我找不到有关如何实际使用它的文档.
What does rdimon
stand for? I understand it is for "semihosting", which means using the host IO somehow. Does this mean I can printf to the host console? I can find no documentation on how to actually use this.
如果我在某处找不到所有这些的真实来源,请告诉我.
If there is a source of truth for all of this somewhere that I haven't found, please let me know.
感谢您帮助澄清.
推荐答案
Gcc 使用 specs-strings,它控制要运行的子进程以及它应该传递给它们的参数.spec-strings 定义的行为可以使用 spec-files 覆盖,其目的和语法记录在此处:https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
Gcc uses specs-strings, which control which subprocesses to run and what parameters it shall pass to them. The behavior defined by the spec-strings can be overridden using spec-files, whose purpose and syntax is documented here: https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
查看gcc工具链的lib文件夹中的这些spec文件(例如/usr/lib/arm-none-eabi/lib
)我们可以看到提到的spec文件定义了哪个标准库将由链接器使用.
Looking at these spec files in the lib folder of the gcc tool chain (e.g. /usr/lib/arm-none-eabi/lib
) we can see that the mentioned spec files define which standard library is to be used by the linker.
例如,nosys.specs
只是定义系统调用应该被实现为调用时返回错误的存根 (-lnosys
).在这种情况下,libc 的选择取决于是否应该使用 nano.使用 %G
处理 libgcc spec-string,它定义了传递给链接器的参数.
For example, nosys.specs
just defines that system calls should be implemented as stubs that return errors when called (-lnosys
). The choice of libc in this case depends on whether nano should be used. With %G
the libgcc spec-string is processed, which defines the parameters passed to the linker.
nosys.specs:
nosys.specs:
%rename link_gcc_c_sequence nosys_link_gcc_c_sequence
*nosys_libgloss:
-lnosys
*nosys_libc:
%{!specs=nano.specs:-lc} %{specs=nano.specs:-lc_nano}
*link_gcc_c_sequence:
%(nosys_link_gcc_c_sequence) --start-group %G %(nosys_libc) %(nosys_libgloss) --end-group
nano.specs
定义了使用 newlib-nano 的系统包含路径和库参数.规范文件包含替换 -lc
和其他 nano 等价物,例如-lc_nano
.因此,将它与这些结合使用将使 gcc 仍然将 nano 库传递给链接器.
nano.specs
defines the system include path and library parameters to use newlib-nano. The spec file contains replacements for -lc
and others to nano equivalents, e.g. -lc_nano
. So using it in conjunction with these will make gcc still pass nano libaries to the linker.
使用rdimon.specs
,-lrdimon
作为标准库的libgloss 部分传递.这基本上意味着您可以使用系统调用(也可以使用 printf),但这依赖于附加的调试器,如果没有调试器,CPU 可能会崩溃.
Using rdimon.specs
, -lrdimon
is passed as the libgloss part of the standard library. This basically means that you can use system calls (and also printf), but this relies on a debugger being attached, and the CPU may crash if no debugger is present.
这篇关于什么是“nosys"、“nano"、“rdimon"?使用 ARM GCC 时的术语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!