From: Jeremy Linton <jeremy.linton@arm.com>
To: Nathan Chancellor <nathan@kernel.org>
Cc: linux-kbuild@vger.kernel.org, masahiroy@kernel.org,
nicolas.schier@linux.dev, linux-kernel@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH] scripts: add zboot support to extract-vmlinux
Date: Fri, 23 May 2025 10:03:58 -0500 [thread overview]
Message-ID: <d97d3229-110f-4aee-93ad-e4499ef4133e@arm.com> (raw)
In-Reply-To: <20250522231009.GA2020750@ax162>
Hi,
Thanks for looking at this.
On 5/22/25 6:10 PM, Nathan Chancellor wrote:
> Hi Jeremy,
>
> On Thu, May 22, 2025 at 12:29:41PM -0500, Jeremy Linton wrote:
>> Zboot compressed kernel images are used for arm 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 vmlinux 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 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.
>>
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> Cc: Ard Biesheuvel <ardb@kernel.org>
>> ---
>> scripts/extract-vmlinux | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
>> index 8995cd304e6e..edda1abe226c 100755
>> --- a/scripts/extract-vmlinux
>> +++ b/scripts/extract-vmlinux
>> @@ -12,10 +12,11 @@
>>
>> 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
>> + file $1 |grep 'Linux kernel.*boot executable Image' > /dev/null
>> + if [ "$?" -ne "0" ]; then
>
> Could these two lines be simplified to:
>
> if file $1 | grep 'Linux kernel.*boot executable Image' > /dev/null; then
Yes, but it needs, a '!', which applies to the last operator in the
pipeline and for clarity should probably drop the redirection, so I
think it ends up:
if ! file $1 | grep -q 'Linux kernel.*boot executable Image'; then
But it mixes the condition checking and the execution, which is common
but maybe not the best idea.
Although, if I'm going to reroll this, i think the " Image" should be
dropped since it can also have zImage and possibly other reports in the
future and AFAIK there isn't any reason to exclude them.
>
>> + # Use readelf to check if it's a valid ELF, if 'file' fails
>> + readelf -h $1 > /dev/null 2>&1 || return 1
>> + fi
>>
>> cat $1
>> exit 0
>> --
>> 2.49.0
>>
next prev parent reply other threads:[~2025-05-23 15:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-22 17:29 [PATCH] scripts: add zboot support to extract-vmlinux Jeremy Linton
2025-05-22 23:10 ` Nathan Chancellor
2025-05-23 15:03 ` Jeremy Linton [this message]
2025-06-07 16:04 ` Masahiro Yamada
2025-06-16 16:07 ` Jeremy Linton
2025-06-24 17:56 ` Masahiro Yamada
2025-07-07 21:29 ` Jeremy Linton
2025-07-07 23:35 ` Masahiro Yamada
2025-07-08 21:30 ` Jeremy Linton
2025-07-07 21:31 ` Jeremy Linton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d97d3229-110f-4aee-93ad-e4499ef4133e@arm.com \
--to=jeremy.linton@arm.com \
--cc=ardb@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas.schier@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.