There is a software package elfutils
which includes a program called eu-elflint
for checking ELF binaries (just as lint
for C - hence the name).
Just for curiosity I have checked our own shared libraries with this tool and it found a lot of issues, 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
As a crosscheck I have build a very trivial shared library from the source code below
int foo(int a) {
return a + 1;
}
// gcc -shared -fPIC -o libfoo.so foo.c
And tried again ...
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
As you can see even the trivial example also shows a lot of issues.
BTW: I am on Ubuntu-Karmic-32bit with gcc v4.4.1
BTW: ... the same happens on Debian-Lenny-64bit with gcc v4.2.4
Is this something I should be concerned about?