2 # extracts .config info from a [b]zImage file
3 # uses: binoffset (new), dd, zcat, strings, grep
4 # $arg1 is [b]zImage filename
6 binoffset
="./scripts/binoffset"
8 IKCFG_ST
="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
9 IKCFG_ED
="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
10 function dump_config
{
13 start
=`$binoffset $file $IKCFG_ST 2>/dev/null`
14 [ "$?" != "0" ] && start
="-1"
15 if [ "$start" -eq "-1" ]; then
18 end
=`$binoffset $file $IKCFG_ED 2>/dev/null`
20 let start
="$start + 8"
21 let size
="$end - $start"
23 head --bytes="$end" "$file" |
tail --bytes="$size" | zcat
32 echo " usage: extract-ikconfig [b]zImage_filename"
37 if [ "$TMPFILE" != "" ]; then
48 TMPFILE
="/tmp/ikconfig-$$"
51 # vmlinux: Attempt to dump the configuration from the file directly
54 GZHDR1
="0x1f 0x8b 0x08 0x00"
55 GZHDR2
="0x1f 0x8b 0x08 0x08"
57 # vmlinux.gz: Check for a compressed images
58 off
=`$binoffset "$image" $GZHDR1 2>/dev/null`
59 [ "$?" != "0" ] && off
="-1"
60 if [ "$off" -eq "-1" ]; then
61 off
=`$binoffset "$image" $GZHDR2 2>/dev/null`
62 [ "$?" != "0" ] && off
="-1"
64 if [ "$off" -eq "0" ]; then
65 zcat
<"$image" >"$TMPFILE"
66 dump_config
"$TMPFILE"
67 elif [ "$off" -ne "-1" ]; then
68 (dd ibs
="$off" skip
=1 count
=0 && dd bs
=512k
) <"$image" 2>/dev
/null | \
70 dump_config
"$TMPFILE"
73 echo "ERROR: Unable to extract kernel configuration information."
74 echo " This kernel image may not have the config info."