美文网首页
清除模块中的debuginfo

清除模块中的debuginfo

作者: 白胡椒 | 来源:发表于2016-10-20 15:03 被阅读0次
#!/bin/sh
#将要提取的文件加到参数中
#set -x
objcopyout()
{
    val=`objdump -s -j .gnu_debuglink "$1" | grep 'Contents of section .gnu_debuglink:'`
    if [ -z "$val" ]; then
        #debug_out=".debug/$1.debug".`date +%s`
        tmp_name=`echo "$1" | awk -F/ '{ print $NF}'`
        debug_out=".debug/$tmp_name.debug".`date +%s`
        objcopy --only-keep-debug "$1" "$debug_out"
        objcopy --strip-debug "$1"
        objcopy --add-gnu-debuglink="$debug_out" "$1"
    fi
}
mkdir -p .debug/
while [ $# -gt 0 ]; do
    if [ -f "$1" ]; then
        objcopyout "$1"
    fi
    shift
done

相关文章

网友评论

      本文标题:清除模块中的debuginfo

      本文链接:https://www.haomeiwen.com/subject/lzbfuttx.html