有是一个软件包elfutils其包括称为eu-elflint用于检查ELF二进制(正如lint对于C - 由此得名)程序

只是为了好奇,我已经查过了自己的共享库,用这个工具,它发现了很多问题,e.g:

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-业报-32位用gcc v4.4.1

顺便说一句:...同样的情况在Debian-莱尼-64位用gcc V4.2.4

这是不是我应该关心?

有帮助吗?

解决方案

快速回答:“这是不是我应该关心?”

更长的答案:elflint检查不仅ABI标准,但也有一些ELF约定。双方的ABI和ELF约定随时间而改变:ABI的延伸,并且必须保持向后兼容,并且ELF规则并随着时间的推移(以获得新的功能,主要是)。因此,elflint的期望必须保持与你的汇编器/连接器(GNU的binutils的在这种情况下)产生同步。你可以找到很多的报告,elflint约在GNU binutils的推出新的ELF扩展,并为这elflint后来只抓住上。因此,它是最有可能的,你有一个版本elflint的太旧,你安装binutils的。由于elflint与其说使用,它不会让我感到吃惊的是一个Linux发行版并没有保持同步,这两个这么好。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top