Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts: add zboot support to extract-vmlinux

Zboot compressed kernel images are used for arm64 kernels on various
distros.

extract-vmlinux fails with those kernels because the wrapped image is
another PE. While this could be a bit confusing, the tools primary
purpose of unwrapping and decompressing the contained kernel image
makes it the obvious place for this functionality.

Add a 'file' check in check_vmlinux() that detects a contained PE
image before trying readelf. Recent (FILES_39, Jun/2020) file
implementations output something like:

"Linux kernel ARM64 boot executable Image, little-endian, 4K pages"

Which is also a stronger statement than readelf provides so drop that
part of the comment. At the same time this means that kernel images
which don't appear to contain a compressed image will be returned
rather than reporting an error. Which matches the behavior for
existing ELF files.

The extracted PE image can then be inspected, or used as would any
other kernel PE.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Jeremy Linton and committed by
Masahiro Yamada
b9f75396 d8f26717

+6 -7
+6 -7
scripts/extract-vmlinux
··· 12 12 13 13 check_vmlinux() 14 14 { 15 - # Use readelf to check if it's a valid ELF 16 - # TODO: find a better to way to check that it's really vmlinux 17 - # and not just an elf 18 - readelf -h $1 > /dev/null 2>&1 || return 1 19 - 20 - cat $1 21 - exit 0 15 + if file "$1" | grep -q 'Linux kernel.*boot executable' || 16 + readelf -h "$1" > /dev/null 2>&1 17 + then 18 + cat "$1" 19 + exit 0 20 + fi 22 21 } 23 22 24 23 try_decompress()