gpt4 book ai didi

gcc - ELF 共享库 : relocation offset out of bounds

转载 作者:行者123 更新时间:2023-12-04 20:30:51 25 4
gpt4 key购买 nike

有一个软件包 elfutils,其中包含一个名为 eu-elflint 的程序,用于检查 ELF 二进制文件(就像 C 的 lint - 因此名字)。

出于好奇,我用这个工具检查了我们自己的共享库,发现了很多问题,例如:

eu-elflint libUtils.so

section [ 2] '.dynsym': _DYNAMIC symbol size 0 does not match dynamic segment size 248
section [ 2] '.dynsym': _GLOBAL_OFFSET_TABLE_ symbol size 0 does not match .got.plt section size 3076
section [ 8] '.rel.plt': relocation 0: offset out of bounds
section [ 8] '.rel.plt': relocation 1: offset out of bounds
...
section [ 8] '.rel.plt': relocation 765: offset out of bounds

作为交叉检查,我从下面的源代码构建了一个非常简单的共享库

int foo(int a) {
return a + 1;
}

// gcc -shared -fPIC -o libfoo.so foo.c

然后再次尝试......

eu-elflint libfoo.so

section [ 9] '.rel.plt': relocation 0: offset out of bounds
section [ 9] '.rel.plt': relocation 1: offset out of bounds
section [23] '.comment' has wrong flags: expected none, is MERGE|STRINGS
section [25] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol size 0 does not match .got.plt section size 20
section [25] '.symtab': _DYNAMIC symbol size 0 does not match dynamic segment size 200

如您所见,即使是微不足道的示例也显示出很多问题。

顺便说一句:我在 Ubuntu-Karmic-32bit 上使用 gcc v4.4.1

顺便说一句:...同样发生在 Debian-Lenny-64bit 和 gcc v4.2.4

这是我应该关心的事情吗?

最佳答案

快速回答:“这是我应该关心的事情吗?” 没有

更长的答案:elflint 不仅检查 ABI 标准,还检查一些 ELF 约定。 ABI 和 ELF 约定都随时间变化:ABI 被扩展,并且必须保持向后兼容,而 ELF 约定确实随着时间的推移而发展(主要是为了获得新功能)。因此,elflint 的期望必须与您的汇编器/链接器(在本例中为 GNU binutils)产生的结果保持同步。您可以在 elflint 上找到很多关于 GNU binutils 中引入的新 ELF 扩展的报告,而 elflint 只会在稍后捕获这些报告。因此,很可能您的 elflint 版本对于您安装的 binutils 来说太旧了。由于 elflint 的使用不多,因此 Linux 发行版不能很好地使这两者保持同步也就不足为奇了。

关于gcc - ELF 共享库 : relocation offset out of bounds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2187169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com