如何防止动态重定位(rela.dyn)?

发布于 2024-08-03 02:12:18 字数 222 浏览 13 评论 0原文

我正在尝试在没有任何操作系统的情况下在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋心╮凉 2024-08-10 02:12:18

如果没有更多信息,很难说。如果您没有底层操作系统,您是否使用 -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?

旧人 2024-08-10 02:12:18

-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文