64 位平台上的 ELF 目标文件大小限制是多少?

发布于 2024-09-28 08:04:22 字数 301 浏览 1 评论 0原文

假设x86 64和linux平台。

如果你查看 ELF 头,偏移量都是 64 位。

因此,通过重定位 R_X86_64_64 可以轻松创建大于 4G 的目标文件。这意味着静态 .o 文件和可执行文件可以与 64 位所能表示的一样大。

但是,对于共享库,例如 gcc ,我们只有 R_X86_64_PLT32 重定位。这意味着不可能创建大于 4GB 的共享库,对吧?

那么如果我想构建一个巨大的程序,其中一个.o文件足够大(>4GB),唯一的选择是静态链接?

欢迎任何评论。

谢谢, 利米

Assume the x86 64 and linux platform.

If you look into the ELF header, the offset are all 64bit.

So it's easy to create an object file larger than 4G with relocatoin R_X86_64_64. This means a static .o file and executable can be as large as 64bit can represent.

However, for shared library, like gcc , we only have R_X86_64_PLT32 relocation. This means that it's impossible to create a shared library large than 4GB, right?

So if I want to build a huge program, one of the .o file is huge enough (>4GB) , the only choice is static linking?

Any comment is welcome.

Thanks,
limi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

愛放△進行李 2024-10-05 08:04:22

Linux 使用的 x86-64 ABI 定义了一个“大型模型”,专门用来避免这种大小限制,包括 GOT 和 PLT 的 64 位重定位类型。 (参见 4.4.2 节中的表格和 3.5.5 节中的指令序列,其中显示了它们的使用方式。)

The x86-64 ABI used by Linux defines a "large model" specifically to avoid such size limitations, which includes 64-bit relocation types for the GOT and PLT. (See the table in section 4.4.2, and the instruction sequences in 3.5.5 which show how they are used.)

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