使用ARMGCC时,什么是“nosys”、“nano”、“rdimon”术语?

我正在学习使用 GCC 工具链编写 ARM 代码。我遇到了一些找不到文档的 GCC 选项。有人可以帮忙解释一下他们是做什么的吗?

  • -specs=nosys.specs
  • -specs=nano.specs
  • -specs=rdimon.specs
  • -lnosys

怎么做-specs=nosys.specs-lnosys关联?你是一起使用它们,还是它们相互排斥,或者其他什么?

和 nano,我收集到暗示使用 newlib-nano 库。我已经看到 this 与-lmand结合使用-lc。这是否只是为您提供标准的 libc 和 libm 函数?

代表什么rdimon?我知道它是用于“半主机”,这意味着以某种方式使用主机 IO。这是否意味着我可以打印到主机控制台?我找不到有关如何实际使用它的文档。

如果我没有找到所有这些的真相来源,请告诉我。

感谢您对澄清的任何帮助。

回答

Gcc 使用specs-strings,它控制要运行的子进程以及它应该传递给它们的参数。规范字符串定义的行为可以使用规范文件覆盖,其目的和语法记录在此处:https : //gcc.gnu.org/onlinedocs/gcc/Spec-Files.html

查看 gcc 工具链(例如/usr/lib/arm-none-eabi/lib)的 lib 文件夹中的这些规范文件,我们可以看到提到的规范文件定义了链接器将使用哪个标准库。

例如,nosys.specs只是定义系统调用应该被实现为调用时返回错误的存根 ( -lnosys)。在这种情况下,libc 的选择取决于是否应该使用nano。与%G所述libgcc中规格字符串被处理,它定义传递给链接器的参数。

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。spec 文件包含-lcnano 等效项的替换和其他内容,例如-lc_nano. 因此,将它与这些结合使用将使 gcc 仍然将 nano 库传递给链接器。

使用rdimon.specs,-lrdimon作为标准库的libgloss部分传递。这基本上意味着您可以使用系统调用(也可以使用 printf),但这依赖于附加的调试器,如果没有调试器,CPU 可能会崩溃。

  • Does it make sense to set both specs in a compile command ("-specs=nano.specs -specs=nosys.specs") and what are the effects you would expect?

    Does this override contents (e.g. functions) of the nano.specs by nosys.specs or does it "only" add non-existing content?

  • @Guti_Haz you can have multiple specs files, and they are processed in order. As these contain directives that may override spec strings, they may conflict. But you can see in the files that they often just append options, so both changes are applied.
  • When you add nano and nosys in that order you get -lnosys and -lc_nano.

以上是使用ARMGCC时,什么是“nosys”、“nano”、“rdimon”术语?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>