summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
authorMichel Thebeau <michel.thebeau@windriver.com>2013-04-10 08:36:47 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-04-11 09:03:21 +0100
commitcd2f003b512adf545dd3e5edd9aad68e09e9cda7 (patch)
treebf3400b03250f4d9ea2f3ee14cf0d188569cbf40 /meta/classes/kernel.bbclass
parent4c02dd5f6432c6e683a57d47b610f56433e9ca0d (diff)
downloadpoky-cd2f003b512adf545dd3e5edd9aad68e09e9cda7.tar.gz
kernel.bbclass: do_strip: allow recipes to strip the kernel
Allow recipes to specify sections to be stripped from the kernel output using KERNEL_IMAGE_STRIP_EXTRA_SECTIONS. For example: KERNEL_IMAGE_STRIP_EXTRA_SECTIONS = ".comment .unwanted" The kernel output is stripped in place. Since the toolchain does not give indication when the specified sections are absent, we read the sections first and make this report by issuing a warning to the developer. The toolchain by default strips the image with the -s option (even when -s is not specified): -s --strip-all Remove all symbol and relocation information For example, these sections are always removed: .debug_aranges .debug_info .debug_abbrev .debug_line .debug_frame .debug_str .debug_loc .debug_ranges .symtab .strtab In addition to these, the sections listed in KERNEL_IMAGE_STRIP_EXTRA_SECTIONS will also be removed. Only stripping of vmlinux (elf) is supported at this time. A warning will be given if the image type is not vmlinux. Stripping the image could also be done in the kernel, but that would only work for linux-yocto based kernels, so it's not the route we decided to go. [YOCTO 3515] (From OE-Core rev: 5f6d33b05b4e7883f2728ca812cb5386d1e36989) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass33
1 files changed, 31 insertions, 2 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index af58887f28..f3a55535fb 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -88,7 +88,7 @@ do_compile_kernelmodules() {
88 bbnote "no modules to compile" 88 bbnote "no modules to compile"
89 fi 89 fi
90} 90}
91addtask compile_kernelmodules after do_compile before do_install 91addtask compile_kernelmodules after do_compile before do_strip
92 92
93kernel_do_install() { 93kernel_do_install() {
94 # 94 #
@@ -289,6 +289,35 @@ python split_kernel_packages () {
289 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') 289 do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
290} 290}
291 291
292do_strip() {
293 if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then
294 if [[ "${KERNEL_IMAGETYPE}" != "vmlinux" ]]; then
295 bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}"
296 return
297 fi
298
299 cd ${B}
300 headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \
301 grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \
302 sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \
303 gawk '{print $1}'`
304
305 for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do {
306 if [[ "$headers" != *"$str"* ]]; then
307 bbwarn "Section not found: $str";
308 fi
309
310 "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT}
311 }; done
312
313 bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \
314 "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}"
315 fi;
316}
317do_strip[dirs] = "${B}"
318
319addtask do_strip before do_sizecheck after do_kernel_link_vmlinux
320
292# Support checking the kernel size since some kernels need to reside in partitions 321# Support checking the kernel size since some kernels need to reside in partitions
293# with a fixed length or there is a limit in transferring the kernel to memory 322# with a fixed length or there is a limit in transferring the kernel to memory
294do_sizecheck() { 323do_sizecheck() {
@@ -302,7 +331,7 @@ do_sizecheck() {
302} 331}
303do_sizecheck[dirs] = "${B}" 332do_sizecheck[dirs] = "${B}"
304 333
305addtask sizecheck before do_install after do_kernel_link_vmlinux 334addtask sizecheck before do_install after do_strip
306 335
307KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}" 336KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}"
308# Don't include the DATETIME variable in the sstate package signatures 337# Don't include the DATETIME variable in the sstate package signatures