Re: Manually checking build id in elf files

Jan Kratochvil
2009-09-03T13:11:15Z

On Thu, 03 Sep 2009 15:03:05 +0200, Alex Bennee wrote:
> I'd like to manually check it but readelf doesn't show any such notes:
>
> vnms@vnms:~$ readelf -n /usr/lib/libcairo.so.2.17.3
> vnms@vnms:~$ readelf -n /usr/lib/debug/usr/lib/libcairo.so.2.17.3

Try elfutils:

# eu-readelf -n /lib64/libc.so.6
Note section [ 1] '.note.gnu.build-id' of 36 bytes at offset 0x270:
Owner Data size Type
GNU 20 GNU_BUILD_ID
Build ID: ec8dd400904ddfcac8b1c343263a790f977159dc
[...]

# eu-unstrip -n -e /lib64/libc.so.6
0x3979600000+0x36d868 ec8dd400904ddfcac8b1c343263a790f977159dc@0x3979600280 /lib64/libc.so.6 /usr/lib/debug/lib64/libc-2.10.1.so.debug

> Am I missing something? Is there a way to use readelf to read this information?

From binutils you can use objdump:

# objdump -s -j .note.gnu.build-id /lib64/libc.so.6
[...]
Contents of section .note.gnu.build-id:
3979600270 04000000 14000000 03000000 474e5500 ............GNU.
----------->
3979600280 ec8dd400 904ddfca c8b1c343 263a790f .....M.....C&:y.
3979600290 977159dc .qY.

Regards,
Jan