All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG?] scripts/extract-vmlinux doesn't produce correct images
@ 2021-06-07  6:18 Grzegorz Zdanowski
  0 siblings, 0 replies; only message in thread
From: Grzegorz Zdanowski @ 2021-06-07  6:18 UTC (permalink / raw)
  To: linux-kernel, kernel-packagers

Hello!

To avoid a XY problem, I will say upfront that I want to:
 1. unpack the x86_64 bzImage
 2. byte-patch it (as the full source is not available)
 3. recompress it back to bzImage to use w/GRUB

Neither the script, commit message
(#09d481270d445d98342d8ab872f05491b6d23f8b) nor LKML thread where the
script was discussed (https://lkml.org/lkml/2011/8/4/168) specified
which "vmlinux" is extracted. I compiled the kernel and ran some tests
after painstakingly analyzing Makefiles.
It looks like "scripts/extract-vmlinux arch/x86/boot/bzImage" extracts
an equivalent of arch/x86/boot/compressed/vmlinux.bin:
# file arch/x86/boot/compressed/vmlinux.bin test-extract
arch/x86/boot/compressed/vmlinux.bin: ELF 64-bit LSB executable,
x86-64, version 1 (SYSV), statically linked,
BuildID[sha1]=2cc29c8d102d8dac8a4cd29539f4364a334f88fd, stripped
test-extract:                         ELF 64-bit LSB executable,
x86-64, version 1 (SYSV), statically linked,
BuildID[sha1]=2cc29c8d102d8dac8a4cd29539f4364a334f88fd, stripped


However the extracted file doesn't match any other file I was able to
find analyzing compilation process. Even with the size of
vmlinux.relocs it will be significantly off.
# ls -1s ... | sort
  11144 arch/x86/boot/compressed/vmlinux.bin.lz4
  11148 arch/x86/boot/compressed/piggy.o
  11200 arch/x86/boot/vmlinux.bin
  11212 arch/x86/boot/compressed/vmlinux
  11416 arch/x86/boot/bzImage
  35752 arch/x86/boot/compressed/vmlinux.bin
  43968 test-extract
      4 arch/x86/boot/compressed/piggy.S
 760924 vmlinux


1. Did I found a problem with extract-vmlinux, or is that script
extracting something else?
2. Is there any other way to binary patch a kernel where only the
bzImage is available?

Apologies if my questions are very basic, I'm just dipping my toes in
the kernel space.

--
Grzegorz "Greg" Zdanowski

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-07  6:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  6:18 [BUG?] scripts/extract-vmlinux doesn't produce correct images Grzegorz Zdanowski

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.