1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-03 13:49:49 +00:00

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>
This commit is contained in:
Saul Wold
2022-01-12 09:20:41 -08:00
committed by Richard Purdie
parent 5ea171985c
commit 987d30df5b
+17 -23
View File
@@ -700,30 +700,19 @@ do_kernel_link_images() {
} }
addtask kernel_link_images after do_compile before do_strip addtask kernel_link_images after do_compile before do_strip
do_strip() { python do_strip() {
if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then import shutil
if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then
bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}"
return
fi
cd ${B} strip = d.getVar('STRIP')
headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \ extra_sections = d.getVar('KERNEL_IMAGE_STRIP_EXTRA_SECTIONS')
grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ kernel_image = d.getVar('B') + "/" + d.getVar('KERNEL_OUTPUT_DIR') + "/vmlinux"
sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \
gawk '{print $1}'`
for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do { if (extra_sections and kernel_image.find('boot/vmlinux') != -1):
if ! (echo "$headers" | grep -q "^$str$"); then kernel_image_stripped = kernel_image + ".stripped"
bbwarn "Section not found: $str"; shutil.copy2(kernel_image, kernel_image_stripped)
fi oe.package.runstrip((kernel_image_stripped, 8, strip, extra_sections))
bb.debug(1, "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections: " + \
"$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux extra_sections)
}; done
bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \
"${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}"
fi;
} }
do_strip[dirs] = "${B}" do_strip[dirs] = "${B}"
@@ -768,7 +757,12 @@ kernel_do_deploy() {
for imageType in ${KERNEL_IMAGETYPES} ; do for imageType in ${KERNEL_IMAGETYPES} ; do
baseName=$imageType-${KERNEL_IMAGE_NAME} baseName=$imageType-${KERNEL_IMAGE_NAME}
install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT}
if [ -s ${KERNEL_OUTPUT_DIR}/$imageType.stripped ] ; then
install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.stripped $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT}
else
install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT}
fi
if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then
ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT}
fi fi