diff options
author | Saul Wold <Saul.Wold@windriver.com> | 2022-01-12 09:20:41 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-01-13 13:57:26 +0000 |
commit | 987d30df5bb18de3cf17d38bbb745ea65cb86266 (patch) | |
tree | 4b4bae9fe9332fda6fe6f20de826a365e3f16bd0 | |
parent | 5ea171985c8fcba857034b64de7c46b0ce364b8d (diff) | |
download | poky-987d30df5bb18de3cf17d38bbb745ea65cb86266.tar.gz |
kernel.bbclass: use common strip()
Re-use the runstrip() code from oe.packaging, for the kernel
stripping process. Since runstrip() is python the kernel do_strip()
need to be converted to Python also. The stripped kernel image
will be used for deployment in do_deploy(). This will allow the
package.bbclass to split an unstripped kernel binary for the debug
information and extended packagedata. The extended package data is
used by create-spdx.
(From OE-Core rev: e8d9caede5f08154ca615fdaba676b7a4ae05b01)
Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/kernel.bbclass | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index 7685c6921f..473e28be47 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
@@ -700,30 +700,19 @@ do_kernel_link_images() { | |||
700 | } | 700 | } |
701 | addtask kernel_link_images after do_compile before do_strip | 701 | addtask kernel_link_images after do_compile before do_strip |
702 | 702 | ||
703 | do_strip() { | 703 | python do_strip() { |
704 | if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then | 704 | import shutil |
705 | if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then | 705 | |
706 | bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}" | 706 | strip = d.getVar('STRIP') |
707 | return | 707 | extra_sections = d.getVar('KERNEL_IMAGE_STRIP_EXTRA_SECTIONS') |
708 | fi | 708 | kernel_image = d.getVar('B') + "/" + d.getVar('KERNEL_OUTPUT_DIR') + "/vmlinux" |
709 | 709 | ||
710 | cd ${B} | 710 | if (extra_sections and kernel_image.find('boot/vmlinux') != -1): |
711 | headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \ | 711 | kernel_image_stripped = kernel_image + ".stripped" |
712 | grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ | 712 | shutil.copy2(kernel_image, kernel_image_stripped) |
713 | sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ | 713 | oe.package.runstrip((kernel_image_stripped, 8, strip, extra_sections)) |
714 | gawk '{print $1}'` | 714 | bb.debug(1, "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections: " + \ |
715 | 715 | extra_sections) | |
716 | for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do { | ||
717 | if ! (echo "$headers" | grep -q "^$str$"); then | ||
718 | bbwarn "Section not found: $str"; | ||
719 | fi | ||
720 | |||
721 | "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux | ||
722 | }; done | ||
723 | |||
724 | bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ | ||
725 | "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" | ||
726 | fi; | ||
727 | } | 716 | } |
728 | do_strip[dirs] = "${B}" | 717 | do_strip[dirs] = "${B}" |
729 | 718 | ||
@@ -768,7 +757,12 @@ kernel_do_deploy() { | |||
768 | 757 | ||
769 | for imageType in ${KERNEL_IMAGETYPES} ; do | 758 | for imageType in ${KERNEL_IMAGETYPES} ; do |
770 | baseName=$imageType-${KERNEL_IMAGE_NAME} | 759 | baseName=$imageType-${KERNEL_IMAGE_NAME} |
771 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT} | 760 | |
761 | if [ -s ${KERNEL_OUTPUT_DIR}/$imageType.stripped ] ; then | ||
762 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.stripped $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT} | ||
763 | else | ||
764 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT} | ||
765 | fi | ||
772 | if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then | 766 | if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then |
773 | ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} | 767 | ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} |
774 | fi | 768 | fi |