URL
https://opencores.org/ocsvn/test_project/test_project/trunk
Subversion Repositories test_project
[/] [test_project/] [trunk/] [linux_sd_driver/] [scripts/] [extract-ikconfig] - Rev 62
Compare with Previous | Blame | View Log
#!/bin/sh# extracts .config info from a [b]zImage file# uses: binoffset (new), dd, zcat, strings, grep# $arg1 is [b]zImage filenamebinoffset="./scripts/binoffset"test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"function dump_config {typeset file="$1"start=`$binoffset $file $IKCFG_ST 2>/dev/null`[ "$?" != "0" ] && start="-1"if [ "$start" -eq "-1" ]; thenreturnfiend=`$binoffset $file $IKCFG_ED 2>/dev/null`let start="$start + 8"let size="$end - $start"dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcatclean_upexit 0}usage(){echo " usage: extract-ikconfig [b]zImage_filename"}clean_up(){if [ "$TMPFILE" != "" ]; thenrm -f $TMPFILEfi}if [ $# -lt 1 ]thenusageexit 1fiTMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1image="$1"# vmlinux: Attempt to dump the configuration from the file directlydump_config "$image"GZHDR1="0x1f 0x8b 0x08 0x00"GZHDR2="0x1f 0x8b 0x08 0x08"# vmlinux.gz: Check for a compressed imagesoff=`$binoffset "$image" $GZHDR1 2>/dev/null`[ "$?" != "0" ] && off="-1"if [ "$off" -eq "-1" ]; thenoff=`$binoffset "$image" $GZHDR2 2>/dev/null`[ "$?" != "0" ] && off="-1"fiif [ "$off" -eq "0" ]; thenzcat <"$image" >"$TMPFILE"dump_config "$TMPFILE"elif [ "$off" -ne "-1" ]; then(dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \zcat >"$TMPFILE"dump_config "$TMPFILE"fiecho "ERROR: Unable to extract kernel configuration information."echo " This kernel image may not have the config info."clean_upexit 1
