如何防止动态重定位(rela.dyn)?
我正在尝试在没有任何操作系统的情况下在 powerpc 嵌入式系统上运行一个简单的程序。我使用 GNU 编译器链接器工具和 PSIM 作为模拟器。我编写了自己的非常简单的链接器指令文件。
我在静态库中使用了全局变量,并希望在示例程序中使用该变量。但在链接示例程序时,GNU ld 给出错误并停止。它说它在链接器指令文件中找不到 rela.dyn。实际上我不想使用动态可重定位库,因为我没有动态加载器。我做错了什么?
I am trying to run a simple program on an powerpc embedded system without any operating system. I am using GNU compiler-linker tools and PSIM as simulator. I've written my own very simple Linker Directive file.
I've used a global variable in my static library and want to use that variable in my sample program. But while linking the sample program GNU ld gives an error and stops. It says that it cannot find rela.dyn in linker directive file. Actually I do not want to use dynamically relocatable library, because I dont have a dynamic loader. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有更多信息,很难说。如果您没有底层操作系统,您是否使用 -ffreestand 来避免在平台运行时进行链接?
编辑: -ffreestand 需要 -shared? -ffreestand 表示编译到非托管环境。这样的环境如何支持共享库?
Hard to say without more info. If you don't have an underlying OS, did you use -ffreestanding to avoid linking in the platform runtime?
Edit: -ffreestanding requires -shared? -ffreestanding means to compile to a non-hosted environment. How can such an environment support shared libraries?
-f独立式,正如 Solar 所说。如果失败,请使用 --verbose 选项运行 ld 来准确查看它试图链接的内容:这将使您能够进一步调试。
-ffreestanding, as Solar says. If that fails, run ld with the --verbose option to see exactly what it is trying to link in: that will enable you to debug further.