美文网首页
extract-vmlinux工具

extract-vmlinux工具

作者: HAPPYers | 来源:发表于2019-07-20 21:10 被阅读0次

项目地址

https://github.com/torvalds/linux/blob/master/scripts/extract-vmlinux

用法

将bzImage提取为vmlinux文件。

./extract-vmlinux ./bzImage > vmlinux

脚本内容

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
# ----------------------------------------------------------------------
# extract-vmlinux - Extract uncompressed vmlinux from a kernel image
#
# Inspired from extract-ikconfig
# (c) 2009,2010 Dick Streefland <dick@streefland.net>
#
# (c) 2011      Corentin Chary <corentin.chary@gmail.com>
#
# ----------------------------------------------------------------------

check_vmlinux()
{
    # Use readelf to check if it's a valid ELF
    # TODO: find a better to way to check that it's really vmlinux
    #       and not just an elf
    readelf -h $1 > /dev/null 2>&1 || return 1

    cat $1
    exit 0
}

try_decompress()
{
    # The obscure use of the "tr" filter is to work around older versions of
    # "grep" that report the byte offset of the line instead of the pattern.

    # Try to find the header ($1) and decompress from here
    for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
    do
        pos=${pos%%:*}
        tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
        check_vmlinux $tmp
    done
}

# Check invocation:
me=${0##*/}
img=$1
if  [ $# -ne 1 -o ! -s "$img" ]
then
    echo "Usage: $me <kernel-image>" >&2
    exit 2
fi

# Prepare temp files:
tmp=$(mktemp /tmp/vmlinux-XXX)
trap "rm -f $tmp" 0

# That didn't work, so retry after decompression.
try_decompress '\037\213\010' xy    gunzip
try_decompress '\3757zXZ\000' abcde unxz
try_decompress 'BZh'          xy    bunzip2
try_decompress '\135\0\0\0'   xxx   unlzma
try_decompress '\211\114\132' xy    'lzop -d'
try_decompress '\002!L\030'   xxx   'lz4 -d'
try_decompress '(\265/\375'   xxx   unzstd

# Finally check for uncompressed images or objects:
check_vmlinux $img

# Bail out:
echo "$me: Cannot find vmlinux." >&2

相关文章

  • extract-vmlinux工具

    项目地址 https://github.com/torvalds/linux/blob/master/script...

  • 工具工具还是工具

    最近几天参加了一个数据分析的训练营,每天晚上8点钟开始,一直讲到10点多,老师很卖力,干货也很多。今天结营,就在这...

  • 2019-01-08 ps总结

    ps 抠图工具 套索工具 多边套索工具 文字工具 磁性套索工具 魔棒工具 渐变工具 蒙版 图章工具 alt 吸取颜...

  • 【工具箱-2-选区工具】

    【工具箱-2-选区工具】 【矩形选框工具组:】矩形选框工具、椭圆选框工具、单行选框工具、单列选框工具。 个人理解:...

  • AI 2019 Mac版常用快捷键大全

    移动工具:V 选取工具:A 钢笔工具:P 添加锚点工具:+ 删除锚点工具:- 文字工具:T 多边形工具:L 矩形、...

  • PS扣图

    1扣图工具 套索工具 多边套索工具 磁性套索工具 快速选择工具 魔棒工具 橡皮擦工具 背景橡皮擦工具 魔术橡皮擦工...

  • AI热键

    选择工具:v 直接选择工具:a 魔棒工具:y 套索工具:q 钢笔工具:p 转换描点工具:Ctrl+c 文字工具:t...

  • 工具?工具人?

    很多时候,我们发明工具的目的是方便工作,结果,适得其反,不仅没有方便,反而增添了工作量。原来往上级交个什么东西,都...

  • 工具的工具

    “一个人越是能够放弃一些东西,越是富有。”-《瓦尔登湖》 当人真正占有一些东西的时候,就成了它们的奴隶,尤其是那些...

  • 去觉知去用你的工具

    去觉知去用你的工具 在空性里, 身体是工具 思想是工具 情绪是工具 情感是工具 人性是工具 …… 发现这些工具 去...

网友评论

      本文标题:extract-vmlinux工具

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