Skip to contentSkip to conversation

extract-vmlinux: Check for uncompressed image as fallback

PATCH In review Helge Deller 2 participants 2 messages Oct 16, 2018 – Oct 17, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extract-vmlinux: Check for uncompressed image as fallback

As on x86-64 and other architectures, the boot kernel on parisc (vmlinuz and bzImage) contains a full compressed copy of the final kernel executable (vmlinux.bin.gz), which one should be able to extract with the extract-vmlinux script.

But on parisc extracting the kernel with extract-vmlinux fails. Currently the script first checks if the given file is an ELF file (which is true on parisc) and if so returns it. Thus on parisc we unexpectedly get back the vmlinuz boot file instead of the uncompressed vmlinux image.

This patch fixes this issue by reverting the logic. It now first tries to find a compression signature in the given file and if that fails it checks the file itself as fallback.

scripts/extract-vmlinux +3 -3
index e6239f39abad..85e1f32fb4a0 100755
@@ -48,9 +48,6 @@ fi
 tmp=$(mktemp /tmp/vmlinux-XXX)
 trap "rm -f $tmp" 0
 
-# Initial attempt for uncompressed images or objects:
-check_vmlinux $img
-
 # That didn't work, so retry after decompression.
 try_decompress '\037\213\010' xy    gunzip
 try_decompress '\3757zXZ\000' abcde unxz
@@ -60,5 +57,8 @@ 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
#1 lore raw

Hi Helge,

Quoted 23 lines · Helge Deller

As on x86-64 and other architectures, the boot kernel on parisc (vmlinuz and bzImage) contains a full compressed copy of the final kernel executable (vmlinux.bin.gz), which one should be able to extract with the extract-vmlinux script.

But on parisc extracting the kernel with extract-vmlinux fails. Currently the script first checks if the given file is an ELF file (which is true on parisc) and if so returns it. Thus on parisc we unexpectedly get back the vmlinuz boot file instead of the uncompressed vmlinux image.

This patch fixes this issue by reverting the logic. It now first tries to find a compression signature in the given file and if that fails it checks the file itself as fallback.

scripts/extract-vmlinux +0 -0
index e6239f39abad..85e1f32fb4a0 100755

scripts/extract-vmlinux fi · line 53

Quoted 6 lines
scripts/extract-vmlinux +0 -3
@@ -48,9 +48,6 @@ fi
 tmp=$(mktemp /tmp/vmlinux-XXX)
 trap "rm -f $tmp" 0
 
-# Initial attempt for uncompressed images or objects:
-check_vmlinux $img
-

This patch looks good in general,
but, I just wondered why this line is needed.

If I understand this correctly,
when vmlinux itself is passed to this script,
it is returned as-is.
But, we already have what we want in this case.

We can simply drop this code if there is no good reason.

CC'ed the submitter of this script, Corentin Chary in case he knows something.

scripts/extract-vmlinux try_decompress '\211\114\132' xy 'lzop -d' · line 64

Quoted 12 lines
scripts/extract-vmlinux +3 -0
 # That didn't work, so retry after decompression.
 try_decompress '\037\213\010' xy    gunzip
 try_decompress '\3757zXZ\000' abcde unxz
@@ -60,5 +57,8 @@ 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

--
Best Regards
Masahiro Yamada