Extract vmlinux from vmlinuz or bzImage

Viewed 37165

I want to generate System.map from vmlinuz,cause most of machines don't have the file System.map.In fact,vmlinuz are compressed to vmlinuz or bzImage.

It's any tool or script can do this?

I tried:

dd if=/boot/vmlinuz skip=`grep -a -b -o -m 1 -e $'\x1f\x8b\x08\x00' /boot/vmlinuz | cut -d: -f 1` bs=1 | zcat > /tmp/vmlinux

It was failed:

zcat: stdin: not in gzip format
32769+0 records in
32768+0 records out
4 Answers

I'm on ubuntu linux.
you can change $'\037\213\010\000' to "$(echo '\037\213\010\000')" in sh

bash$ N=$(grep -abo -m1  $'\037\213\010\000' vmlinuz-4.13.0-37-generic | awk -F: '{print $1+1}') && 
tail -c +$N vmlinuz-4.13.0-37-generic | gzip -d > /tmp/vmlinuz

try this :

dd if=vmlinuz bs=1 skip=24584 | zcat > vmlinux

with

24584 = 24576 + 8

when

od -A d -t x1 vmlinuz | grep '1f 8b 08 00'

gives

....... 0  1  2  3  .  .  .  .  8  
0024576 24 26 27 00 ae 21 16 00 1f 8b 08 00 7f 2f 6b 45

enjoy !

Related