从 vmlinuz 或 bzImage 中提取 vmlinux [英] Extract vmlinux from vmlinuz or bzImage
问题描述
我想从vmlinuz生成System.map,因为大多数机器没有System.map文件.实际上vmlinuz被压缩成vmlinuz或bzImage.
I want to generate System.map from vmlinuz,cause most of machines don't have the file System.map.In fact,vmlinuz are compressed to vmlinuz or bzImage.
有什么工具或脚本可以做到这一点吗?
It's any tool or script can do this?
我试过了:
dd if=/boot/vmlinuz skip=`grep -a -b -o -m 1 -e $'x1fx8bx08x00' /boot/vmlinuz | cut -d: -f 1` bs=1 | zcat > /tmp/vmlinux
失败了:
zcat: stdin: not in gzip format
32769+0 records in
32768+0 records out
推荐答案
要从内核映像中提取未压缩的内核,可以使用 scripts
中的 extract-vmlinux
脚本code> 内核树中的目录(至少在内核版本 3.5 中可用)(如果您收到类似
To extract the uncompressed kernel from the kernel image, you can use the extract-vmlinux
script from the scripts
directory in the kernel tree (available at least in kernel version 3.5) (if you get an error like
mktemp:无法创建临时文件/tmp/vmlinux-XXX:参数无效
mktemp: Cannot create temp file /tmp/vmlinux-XXX: Invalid argument
您需要在脚本中将 $(mktemp/tmp/vmlinux-XXX)
替换为 $(mktemp/tmp/vmlinux-XXXXXX)
).命令是 /path/to/kernel/tree/scripts/extract-vmlinux <kernel image>>vmlinux
.
you need to replace $(mktemp /tmp/vmlinux-XXX)
by $(mktemp /tmp/vmlinux-XXXXXX)
in the script). The command is /path/to/kernel/tree/scripts/extract-vmlinux <kernel image> >vmlinux
.
如果提取的内核二进制文件包含符号信息,您应该能够使用同一子目录中的 mksysmap
脚本创建 System.map
文件.这里的命令是NM=nm/path/to/kernel/tree/scripts/mksysmap vmlinux System.map
.
If the extracted kernel binary contains symbol information, you should¹ be able to create the System.map
file using the mksysmap
script from the same subdirectory. The command here is NM=nm /path/to/kernel/tree/scripts/mksysmap vmlinux System.map
.
¹ 我的发行版附带的内核映像似乎已被剥离,因此脚本无法获取符号.
¹ The kernel images shipped with my distribution seem to be stripped, so the script was not able to get the symbols.
这篇关于从 vmlinuz 或 bzImage 中提取 vmlinux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!