* [RFC] [PATCH 0/2] Routerstation Pro: kernel.bbclass: do_sizecheck, do_strip
@ 2013-04-08 20:15 michel.thebeau
2013-04-08 20:15 ` [PATCH 1/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete michel.thebeau
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: michel.thebeau @ 2013-04-08 20:15 UTC (permalink / raw)
To: richard.purdie; +Cc: Bruce.Ashfield, Michel.Thebeau, openembedded-core
Hi Richard,
Here is request for comment, v2 of fixes to kernel.bbclass for 3514 and
3514 bugs (and now bug 4220).
For the first patch you had asked that KERNEL_OUTPUT be used
consistently for the kernel.
The second patch is new, and what I'm especially looking for comments
on. It is to get back to what 3515 original said, to strip the elf
image, and what Bruce said: finding the right place to strip the image.
Commit 9cd3816e4db97c8fd093a120a75a2b5d193afcdd didn't quite work,
which made vmlinux.bin (binary format) the default kernel image. See
also bug 4220.
FYI, the binary vmlinux.bin does boot when you know how. 0x806a5430
comes from copying the entry address of the elf.
RedBoot> load -v -m tftp -h 128.224.149.6 -b 0x80060000 -r mthebeau/vmlinux.bin
RedBoot> exec -b 0x80060000 -c "console=ttyS0,115200 root=/dev/sda1 rw rootdelay=2 board=UBNT-RSPRO" 0x806a5430
I have a version of this patch that strips the kernel in place
instead of carrying a copy. One reason to carry a seperate copy could
be the following build warning, which is issued when stripping the
image in place:
WARNING: File '/usr/src/kernel/arch/mips/boot/vmlinux.stripped' from
linux-yocto was already stripped, this will prevent future debugging!
A third patch here for your reference only; will resend it to the poky
list if you like this approach.
Thanks,
M
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete 2013-04-08 20:15 [RFC] [PATCH 0/2] Routerstation Pro: kernel.bbclass: do_sizecheck, do_strip michel.thebeau @ 2013-04-08 20:15 ` michel.thebeau 2013-04-08 20:15 ` [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel michel.thebeau 2013-04-08 20:15 ` [poky] [PATCH 1/1] routerstationpro: strip the output kernel of .comment section michel.thebeau 2 siblings, 0 replies; 10+ messages in thread From: michel.thebeau @ 2013-04-08 20:15 UTC (permalink / raw) To: richard.purdie; +Cc: Bruce.Ashfield, Michel.Thebeau, openembedded-core From: Michel Thebeau <michel.thebeau@windriver.com> do_sizecheck has a few issues especially with vmlinux image type. It breaks because KERNEL_OUTPUT is a path relative to ${B}. When do_sizecheck runs it does not find the file (because the working directory is elsewhere) and does not fail. Also, the image file referenced by KERNEL_OUTPUT may be a link. Finally, when do_sizecheck deletes the oversized kernel image it leaves the previously run do_compile task with inaccurate status. So, do the following: - specify that the working directory should be ${B} - use ls -L to reference to the real file, and ensure that the link file is created - keep the oversized image file so the status of do_compile is valid [YOCTO #3514] Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> --- meta/classes/kernel.bbclass | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index d57d1f5..af58887 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass @@ -293,15 +293,16 @@ python split_kernel_packages () { # with a fixed length or there is a limit in transferring the kernel to memory do_sizecheck() { if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then - size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'` + cd ${B} + size=`ls -lL ${KERNEL_OUTPUT} | awk '{ print $5}'` if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then - rm ${KERNEL_OUTPUT} die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular." fi fi } +do_sizecheck[dirs] = "${B}" -addtask sizecheck before do_install after do_compile +addtask sizecheck before do_install after do_kernel_link_vmlinux KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}" # Don't include the DATETIME variable in the sstate package signatures -- 1.7.9.7 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 20:15 [RFC] [PATCH 0/2] Routerstation Pro: kernel.bbclass: do_sizecheck, do_strip michel.thebeau 2013-04-08 20:15 ` [PATCH 1/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete michel.thebeau @ 2013-04-08 20:15 ` michel.thebeau 2013-04-08 20:54 ` Richard Purdie 2013-04-08 20:15 ` [poky] [PATCH 1/1] routerstationpro: strip the output kernel of .comment section michel.thebeau 2 siblings, 1 reply; 10+ messages in thread From: michel.thebeau @ 2013-04-08 20:15 UTC (permalink / raw) To: richard.purdie; +Cc: Bruce.Ashfield, Michel.Thebeau, openembedded-core From: Michel Thebeau <michel.thebeau@windriver.com> 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 file to be stripped is a copy of ${KERNEL_OUTPUT} and will be given the same name with an additional ".stripped" suffix. The suffix can be overridden using KERNEL_STRIP_SUFFIX. 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] Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> --- meta/classes/kernel.bbclass | 65 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index af58887..60da4e2 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass @@ -41,6 +41,10 @@ KERNEL_RELEASE ?= "${KERNEL_VERSION}" KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}" KERNEL_IMAGEDEST = "boot" +# When we strip the output, it is here +KERNEL_STRIPPED_SUFFIX ?= ".stripped" +KERNEL_OUTPUT_STRIPPED ?= "${KERNEL_OUTPUT}${KERNEL_STRIPPED_SUFFIX}" + # # configuration # @@ -109,6 +113,12 @@ kernel_do_install() { install -d ${D}/${KERNEL_IMAGEDEST} install -d ${D}/boot install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} + + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + install -m 0644 ${KERNEL_OUTPUT_STRIPPED} \ + ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}${KERNEL_STRIPPED_SUFFIX} + fi; + install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} @@ -153,6 +163,12 @@ kernel_do_install() { cd "$pwd" fi install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE} + + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + install -m 0644 ${KERNEL_OUTPUT_STRIPPED} \ + $kerneldir/${KERNEL_IMAGETYPE}${KERNEL_STRIPPED_SUFFIX} + fi + install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION} # @@ -289,12 +305,46 @@ python split_kernel_packages () { do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') } +do_strip() { + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + if [[ "${KERNEL_IMAGETYPE}" != "vmlinux" ]]; then + bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}" + return + fi + + cd ${B} + cp ${KERNEL_OUTPUT} ${KERNEL_OUTPUT_STRIPPED} + + headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_STRIPPED} | \ + grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ + sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ + gawk '{print $1}'` + + for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do { + if [[ "$headers" != *"$str"* ]]; then + bbwarn "Section not found: $str"; + fi + + "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_STRIPPED} + }; done + fi; +} +do_strip[dirs] = "${B}" + +addtask do_strip before do_sizecheck after do_kernel_link_vmlinux + # Support checking the kernel size since some kernels need to reside in partitions # with a fixed length or there is a limit in transferring the kernel to memory do_sizecheck() { + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + koutf=${KERNEL_OUTPUT_STRIPPED} + else + koutf=${KERNEL_OUTPUT} + fi + if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then cd ${B} - size=`ls -lL ${KERNEL_OUTPUT} | awk '{ print $5}'` + size=`ls -lL $koutf | awk '{ print $5}'` if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular." fi @@ -302,7 +352,7 @@ do_sizecheck() { } do_sizecheck[dirs] = "${B}" -addtask sizecheck before do_install after do_kernel_link_vmlinux +addtask sizecheck before do_install after do_strip KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}" # Don't include the DATETIME variable in the sstate package signatures @@ -342,6 +392,10 @@ addtask uboot_mkimage before do_install after do_compile kernel_do_deploy() { install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + install -m 0644 ${KERNEL_OUTPUT_STRIPPED} \ + ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}${KERNEL_STRIPPED_SUFFIX}.bin + fi if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib ln -sf ${MODULE_TARBALL_BASE_NAME}.bin ${MODULE_TARBALL_SYMLINK_NAME} @@ -352,6 +406,13 @@ kernel_do_deploy() { ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGE_SYMLINK_NAME}.bin ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGETYPE} + if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then + ln -sf ${KERNEL_IMAGE_BASE_NAME}${KERNEL_STRIPPED_SUFFIX}.bin \ + ${KERNEL_IMAGE_SYMLINK_NAME}${KERNEL_STRIPPED_SUFFIX}.bin + ln -sf ${KERNEL_IMAGE_BASE_NAME}${KERNEL_STRIPPED_SUFFIX}.bin \ + ${KERNEL_IMAGETYPE}${KERNEL_STRIPPED_SUFFIX} + fi + cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt cd - } -- 1.7.9.7 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 20:15 ` [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel michel.thebeau @ 2013-04-08 20:54 ` Richard Purdie 2013-04-08 21:24 ` Michel Thebeau 2013-04-08 21:24 ` michel.thebeau 0 siblings, 2 replies; 10+ messages in thread From: Richard Purdie @ 2013-04-08 20:54 UTC (permalink / raw) To: michel.thebeau; +Cc: Bruce.Ashfield, openembedded-core On Mon, 2013-04-08 at 16:15 -0400, michel.thebeau@windriver.com wrote: > From: Michel Thebeau <michel.thebeau@windriver.com> > > 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 file to be stripped is a copy of ${KERNEL_OUTPUT} and will be given > the same name with an additional ".stripped" suffix. The suffix can be > overridden using KERNEL_STRIP_SUFFIX. > > 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] > > Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> > Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> Can we please just have one output kernel, not two. Is the unstripped version useful anywhere? Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 20:54 ` Richard Purdie @ 2013-04-08 21:24 ` Michel Thebeau 2013-04-08 21:24 ` michel.thebeau 1 sibling, 0 replies; 10+ messages in thread From: Michel Thebeau @ 2013-04-08 21:24 UTC (permalink / raw) To: Richard Purdie; +Cc: Bruce.Ashfield, openembedded-core On 13-04-08 04:54 PM, Richard Purdie wrote: > On Mon, 2013-04-08 at 16:15 -0400, michel.thebeau@windriver.com wrote: >> From: Michel Thebeau <michel.thebeau@windriver.com> >> >> 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 file to be stripped is a copy of ${KERNEL_OUTPUT} and will be given >> the same name with an additional ".stripped" suffix. The suffix can be >> overridden using KERNEL_STRIP_SUFFIX. >> >> 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] >> >> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> >> Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> > > Can we please just have one output kernel, not two. Is the unstripped > version useful anywhere? > The unstripped image is bootable, and it is conceivable that someone may even want to do load -m tftp from the boot script. But, if a single image is desirable then I'd go with the image stripped in place. Here is that other patch... I'll make sure to add text to the log so it is clear about what happened to the image. M > Cheers, > > Richard > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 20:54 ` Richard Purdie 2013-04-08 21:24 ` Michel Thebeau @ 2013-04-08 21:24 ` michel.thebeau 2013-04-08 21:28 ` Michel Thebeau 1 sibling, 1 reply; 10+ messages in thread From: michel.thebeau @ 2013-04-08 21:24 UTC (permalink / raw) To: richard.purdie; +Cc: Bruce.Ashfield, Michel.Thebeau, openembedded-core From: Michel Thebeau <michel.thebeau@windriver.com> Allow recipes to specify sections to be stripped from the kernel output using KERNEL_IMAGE_STRIP. For example: KERNEL_IMAGE_STRIP = ".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 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] Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> --- meta/classes/kernel.bbclass | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index af58887..4c2c9b9 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass @@ -88,7 +88,7 @@ do_compile_kernelmodules() { bbnote "no modules to compile" fi } -addtask compile_kernelmodules after do_compile before do_install +addtask compile_kernelmodules after do_compile before do_strip kernel_do_install() { # @@ -289,6 +289,32 @@ python split_kernel_packages () { do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') } +do_strip() { + if [ -n "${KERNEL_IMAGE_STRIP}" ]; then + if [[ "${KERNEL_IMAGETYPE}" != "vmlinux" ]]; then + bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}" + return + fi + + cd ${B} + headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \ + grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ + sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ + gawk '{print $1}'` + + for str in ${KERNEL_IMAGE_STRIP}; do { + if [[ "$headers" != *"$str"* ]]; then + bbwarn "Section not found: $str"; + fi + + "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT} + }; done + fi; +} +do_strip[dirs] = "${B}" + +addtask do_strip before do_sizecheck after do_kernel_link_vmlinux + # Support checking the kernel size since some kernels need to reside in partitions # with a fixed length or there is a limit in transferring the kernel to memory do_sizecheck() { @@ -302,7 +328,7 @@ do_sizecheck() { } do_sizecheck[dirs] = "${B}" -addtask sizecheck before do_install after do_kernel_link_vmlinux +addtask sizecheck before do_install after do_strip KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}" # Don't include the DATETIME variable in the sstate package signatures -- 1.7.9.7 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 21:24 ` michel.thebeau @ 2013-04-08 21:28 ` Michel Thebeau 2013-04-08 21:48 ` Richard Purdie 0 siblings, 1 reply; 10+ messages in thread From: Michel Thebeau @ 2013-04-08 21:28 UTC (permalink / raw) To: richard.purdie; +Cc: Bruce.Ashfield, openembedded-core On 13-04-08 05:24 PM, michel.thebeau@windriver.com wrote: > From: Michel Thebeau <michel.thebeau@windriver.com> > > Allow recipes to specify sections to be stripped from the kernel output > using KERNEL_IMAGE_STRIP. For example: > > KERNEL_IMAGE_STRIP = ".comment .unwanted" s/KERNEL_IMAGE_STRIP/KERNEL_IMAGE_STRIP_EXTRA_SECTIONS Throughout > > The kernel output is stripped in place. The subject was supposed to say "v2" > > 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 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] > > Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> > --- > meta/classes/kernel.bbclass | 30 ++++++++++++++++++++++++++++-- > 1 file changed, 28 insertions(+), 2 deletions(-) > > diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass > index af58887..4c2c9b9 100644 > --- a/meta/classes/kernel.bbclass > +++ b/meta/classes/kernel.bbclass > @@ -88,7 +88,7 @@ do_compile_kernelmodules() { > bbnote "no modules to compile" > fi > } > -addtask compile_kernelmodules after do_compile before do_install > +addtask compile_kernelmodules after do_compile before do_strip > > kernel_do_install() { > # > @@ -289,6 +289,32 @@ python split_kernel_packages () { > do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') > } > > +do_strip() { > + if [ -n "${KERNEL_IMAGE_STRIP}" ]; then > + if [[ "${KERNEL_IMAGETYPE}" != "vmlinux" ]]; then > + bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}" > + return > + fi > + > + cd ${B} > + headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \ > + grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ > + sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ > + gawk '{print $1}'` > + > + for str in ${KERNEL_IMAGE_STRIP}; do { > + if [[ "$headers" != *"$str"* ]]; then > + bbwarn "Section not found: $str"; > + fi > + > + "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT} > + }; done And I'll add a comment here bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" Michel > + fi; > +} > +do_strip[dirs] = "${B}" > + > +addtask do_strip before do_sizecheck after do_kernel_link_vmlinux > + > # Support checking the kernel size since some kernels need to reside in partitions > # with a fixed length or there is a limit in transferring the kernel to memory > do_sizecheck() { > @@ -302,7 +328,7 @@ do_sizecheck() { > } > do_sizecheck[dirs] = "${B}" > > -addtask sizecheck before do_install after do_kernel_link_vmlinux > +addtask sizecheck before do_install after do_strip > > KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PE}-${PV}-${PR}-${MACHINE}-${DATETIME}" > # Don't include the DATETIME variable in the sstate package signatures > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 21:28 ` Michel Thebeau @ 2013-04-08 21:48 ` Richard Purdie 2013-04-09 12:44 ` Michel Thebeau 0 siblings, 1 reply; 10+ messages in thread From: Richard Purdie @ 2013-04-08 21:48 UTC (permalink / raw) To: Michel Thebeau; +Cc: Bruce.Ashfield, openembedded-core On Mon, 2013-04-08 at 17:28 -0400, Michel Thebeau wrote: > > On 13-04-08 05:24 PM, michel.thebeau@windriver.com wrote: > > From: Michel Thebeau <michel.thebeau@windriver.com> > > > > Allow recipes to specify sections to be stripped from the kernel output > > using KERNEL_IMAGE_STRIP. For example: > > > > KERNEL_IMAGE_STRIP = ".comment .unwanted" > > s/KERNEL_IMAGE_STRIP/KERNEL_IMAGE_STRIP_EXTRA_SECTIONS > > Throughout So are you resending this with the appropriate changes, tested? It looks much better this way to me than the first version anyway, thanks. Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel 2013-04-08 21:48 ` Richard Purdie @ 2013-04-09 12:44 ` Michel Thebeau 0 siblings, 0 replies; 10+ messages in thread From: Michel Thebeau @ 2013-04-09 12:44 UTC (permalink / raw) To: Richard Purdie; +Cc: Bruce.Ashfield, openembedded-core On 13-04-08 05:48 PM, Richard Purdie wrote: > On Mon, 2013-04-08 at 17:28 -0400, Michel Thebeau wrote: >> >> On 13-04-08 05:24 PM, michel.thebeau@windriver.com wrote: >>> From: Michel Thebeau <michel.thebeau@windriver.com> >>> >>> Allow recipes to specify sections to be stripped from the kernel output >>> using KERNEL_IMAGE_STRIP. For example: >>> >>> KERNEL_IMAGE_STRIP = ".comment .unwanted" >> >> s/KERNEL_IMAGE_STRIP/KERNEL_IMAGE_STRIP_EXTRA_SECTIONS >> >> Throughout > > So are you resending this with the appropriate changes, tested? It looks > much better this way to me than the first version anyway, thanks. > Yes, I will update this patch to address the same comments given for the first version and retest before sending it out. Thanks Richard, M > Richard > > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [poky] [PATCH 1/1] routerstationpro: strip the output kernel of .comment section 2013-04-08 20:15 [RFC] [PATCH 0/2] Routerstation Pro: kernel.bbclass: do_sizecheck, do_strip michel.thebeau 2013-04-08 20:15 ` [PATCH 1/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete michel.thebeau 2013-04-08 20:15 ` [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel michel.thebeau @ 2013-04-08 20:15 ` michel.thebeau 2 siblings, 0 replies; 10+ messages in thread From: michel.thebeau @ 2013-04-08 20:15 UTC (permalink / raw) To: richard.purdie; +Cc: Bruce.Ashfield, Michel.Thebeau, openembedded-core From: Michel Thebeau <michel.thebeau@windriver.com> The routerstationpro has a 16mb flash which the kernel image should fit into. The default build type for vmlinux then should be a stripped vmlinux. Use KERNEL_IMAGE_STRIP_EXTRA_SECTIONS to do this. Reverts commit 9cd3816e4db97c8fd093a120a75a2b5d193afcdd, which causes: RedBoot> load -v vlm-boards/19256/kernel Using default protocol (TFTP) Unrecognized image type: 0x0 [YOCTO 3515] [YOCTO 4220] Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com> --- meta-yocto-bsp/conf/machine/routerstationpro.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meta-yocto-bsp/conf/machine/routerstationpro.conf b/meta-yocto-bsp/conf/machine/routerstationpro.conf index a727e2a..723625b 100644 --- a/meta-yocto-bsp/conf/machine/routerstationpro.conf +++ b/meta-yocto-bsp/conf/machine/routerstationpro.conf @@ -6,8 +6,9 @@ require conf/machine/include/tune-mips32.inc MACHINE_FEATURES = "screen keyboard pci usbhost ext2 ext3 serial" -KERNEL_ALT_IMAGETYPE = "vmlinux" -KERNEL_IMAGETYPE = "vmlinux.bin" +KERNEL_IMAGETYPE = "vmlinux" +KERNEL_ALT_IMAGETYPE = "vmlinux.bin" +KERNEL_IMAGE_STRIP_EXTRA_SECTIONS = ".comment" PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto" PREFERRED_VERSION_linux-yocto ?= "3.4%" -- 1.7.9.7 ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-04-09 13:02 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-08 20:15 [RFC] [PATCH 0/2] Routerstation Pro: kernel.bbclass: do_sizecheck, do_strip michel.thebeau 2013-04-08 20:15 ` [PATCH 1/2] kernel.bbclass: do_sizecheck: update path to build image and do not delete michel.thebeau 2013-04-08 20:15 ` [PATCH 2/2] kernel.bbclass: do_strip: allow recipes to strip the kernel michel.thebeau 2013-04-08 20:54 ` Richard Purdie 2013-04-08 21:24 ` Michel Thebeau 2013-04-08 21:24 ` michel.thebeau 2013-04-08 21:28 ` Michel Thebeau 2013-04-08 21:48 ` Richard Purdie 2013-04-09 12:44 ` Michel Thebeau 2013-04-08 20:15 ` [poky] [PATCH 1/1] routerstationpro: strip the output kernel of .comment section michel.thebeau
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox