反汇编及连接工具

 

######################################################################
#
# this is a disassembly tool,convenient to debug
#
# input Params:
#       $1: filename    :*.dll that you want disassembly module
#       $2: address     :entrypoint address that *.efi entry point address of low 32 bit,if 64 bit will error
#       $3: gcc version :our platform support gcc44 or gcc49

# output file:
#       a:filename.asm     :asm file that original deal with *.dll file
#       b:filename.asm.ld :asm file that link entry point address
#
# note:
#     if the module type is Sec the entry point address is 9fc11094
#     if the module type is't Sec please find this module(*.efi) entry point address that low 32 bit address as $2 params.
#
# sample:
#       ./DebugTool SecMain.dll 9fc11094 gcc44
#       ./DebugTool BootparamsDxe.dll 0E647240 gcc49
#
#######################################################################


!/bin/sh

BINFILE=$1.bin
ASMFILE=$1.asm

if  [[ ! -f `find ./ -name $ASMFILE` || ! -f `find ./ -name $ASMFILE.ld` ]];then
echo
else
echo $ASMFILE.ld already exiting will rm it.
  rm -rf $ASMFILE
  rm -rf $ASMFILE.ld
fi

if [ "$3" == "gcc44" ]; then
/opt/gcc-4.4.0-pmon/bin/mipsel-linux-objcopy -O binary $1 $BINFILE
/opt/gcc-4.4.0-pmon/bin/mipsel-linux-objdump -D -b binary -m mips $BINFILE > $ASMFILE
elif [ "$3" == "gcc49" ]; then
/opt/cross-gcc-4.9.3-n64-loongson-rc6.1/usr/bin/mips64el-loongson-linux-objcopy -O binary $1 $BINFILE
/opt/cross-gcc-4.9.3-n64-loongson-rc6.1/usr/bin/mips64el-loongson-linux-objdump -D -b binary -m mips $BINFILE > $ASMFILE
fi

cat $ASMFILE | while read LINE
do
  if [[ `echo $LINE |grep ':' |wc -l` -ne 0 && `echo $LINE |grep '<.data>:' |wc -l` -le 0 ]];
  then
    a=`echo ${LINE}|cut -d ':' -f1`
    if [[ $a == *[0-9]* ]]; then
    let b=0x$a
    let plus=0x$2
    ((c=$b+$plus))
    d=`echo "obase=16;$c"|bc`
    e=`tr '[A-Z]' '[a-z]' <<<"$d"`
    mm=`echo ${LINE}|cut -d ':' -f2`
    new="${e}:${mm}"
    echo $new >> $ASMFILE.ld
  fi
  else
    echo $LINE >> $ASMFILE.ld
  fi
done

rm -rf $BINFILE

exit $?

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值