public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] kernel-install.eclass: fix gentoo-kernel-bin with llvm-objcopy
@ 2024-09-17 11:57 Andrew Ammerlaan
  0 siblings, 0 replies; only message in thread
From: Andrew Ammerlaan @ 2024-09-17 11:57 UTC (permalink / raw
  To: gentoo-dev; +Cc: Andrew Ammerlaan

We ship the kernel in gentoo-kernel-bin in the form of an UKI, using
objcopy we extract from this the kernel image (and if desired the
generic initramfs).

However, llvm-objcopy does not properly handle the -O argument and as a
result the extracted kernel image is of the same file type as the UKI
(i.e. a PE32+ executable) instead of a regular kernel image. This causes
issues in bootloader such as grub which differentiate between loading
a normal kernel image and loading an EFI executable (such as an UKI).
And also causes the signature verification to fail since the kernel
image is bigger then it should be due to the additional headers.

Using the --dump-section argument instead resolves this problem.

See-also: https://github.com/llvm/llvm-project/issues/108946
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/38643
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/kernel-install.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 930640188c26..dc337c7862fd 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -650,7 +650,7 @@ kernel-install_extract_from_uki() {
 	local uki=${2}
 	local out=${3}
 
-	$(tc-getOBJCOPY) -O binary "-j.${extract_type}" "${uki}" "${out}" ||
+	$(tc-getOBJCOPY) "${uki}" --dump-section ".${extract_type}=${out}" ||
 		die "Failed to extract ${extract_type}"
 	chmod 644 "${out}" || die
 }
-- 
2.46.0



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

only message in thread, other threads:[~2024-09-17 11:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 11:57 [gentoo-dev] [PATCH] kernel-install.eclass: fix gentoo-kernel-bin with llvm-objcopy Andrew Ammerlaan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox