8953系列----parse vmlinux

来源:互联网 发布:严歌苓 知乎 编辑:程序博客网 时间:2024/05/01 01:51

 搞了个解析脚本

#!/bin/bashINPUT=$1OUTPUT=$2TOOLDIR=$3symbol[0]="swapper_pg_dir"symbol[1]="stext"symbol[2]="linux_banner"symbol[3]="kernel_config_data"symbol[4]="saved_command_line"symbol[5]="log_first_idx"symbol[6]="log_next_idx"symbol[7]="log_buf"symbol[8]="__log_align"struct[0]="printk_log"field[0]="ts_nsec"field[1]="len"field[2]="text_len"field[3]="dict_len"field[4]="magic"struct[1]="__log_buf"rm -f $(dirname $OUTPUT)/Symbol.configi=0num_of_symbols=${#symbol[@]}$TOOLDIR/x86_64-linux-android-nm $INPUT > $(dirname $OUTPUT)/tmpfilewhile [ $i -lt $num_of_symbols ]doaddr=`grep -w ${symbol[i]}  $(dirname $OUTPUT)/tmpfile| cut -d' ' -f1`echo "symbol@${symbol[i]}:$addr;" >> $OUTPUTi=$((i+1))donej=0num_of_fields=${#field[@]}$TOOLDIR/x86_64-linux-android-objdump -g $INPUT 2>/dev/null | egrep 'Abbrev|DW' \| grep printk_log -A60 > $(dirname $OUTPUT)/dumpkeyinfowhile [ $j -lt $num_of_fields ]dodec_offset=`grep -w ${field[j]} -A8 $(dirname $OUTPUT)/dumpkeyinfo | grep DW_AT_data_member_location | cut -d':' -f2 | tr -d ' '`offset=`printf "%x" $dec_offset`echo "field_offset@struct ${struct[0]}@${field[j]}:$offset;" >> $OUTPUTj=$((j+1))donedec_size_of_struct0=`grep -A4 ${struct[0]} $(dirname $OUTPUT)/dumpkeyinfo | grep DW_AT_byte_size | cut -d':' -f2 | tr -d ' '`size_of_struct0=`printf "%x" $dec_size_of_struct0`echo "size_of@struct ${struct[0]}:$size_of_struct0;" >> $OUTPUTori_size_of_struct1=`$TOOLDIR/x86_64-linux-android-objdump -t $INPUT | grep ${struct[1]} | cut -f2 | cut -d' ' -f1`size_of_struct1=`printf "%x" 0x$ori_size_of_struct1`echo "size_of@${struct[1]}:$size_of_struct1;" >> $OUTPUTrm -f $(dirname $OUTPUT)/dumpkeyinform -f $(dirname $OUTPUT)/tmpfile


0 0
原创粉丝点击