Message ID | 20201230200441.611456-1-rsalvaterra@gmail.com |
---|---|
State | Accepted |
Delegated to: | Hauke Mehrtens |
Headers | show |
Series | kernel-build: fix STRIP_KERNEL_EXPORTS for 64-bit kernels | expand |
On 12/30/20 9:04 PM, Rui Salvaterra wrote: > While parsing the nm output, we need to account for the fact that 64-bit kernels > have 64-bit wide addresses. While at it, replace the grep | sed combo with a > single awk invocation and a stronger regex. > > Fixes: 2ef0acc5fcda557fa5aaad35d27cb8cf75be96d2 "kernel-build: fix > STRIP_KERNEL_EXPORTS for recent kernels" > > Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com> > --- > include/kernel-build.mk | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/kernel-build.mk b/include/kernel-build.mk > index 22f7c4c7c7..6123c9d456 100644 > --- a/include/kernel-build.mk > +++ b/include/kernel-build.mk > @@ -105,7 +105,7 @@ define BuildKernel > xargs $(TARGET_CROSS)nm | \ > awk '$$$$1 == "U" { print $$$$2 } ' | \ > sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt > - $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt > + $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt > grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt > grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt > ( \ > Hi, On the ipq40xx target the results of both commands are different. The original command removed the __ksymtab_ prefix, you do not remove it. Original result: ---------------------------- hauke@hauke-t480:~/openwrt/openwrt$ ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm -n build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' |sort |head -5 __ablkcipher_walk_complete ablkcipher_walk_done ablkcipher_walk_phys abort abort_creds ---------------------------- Result with your change: ---------------------------- hauke@hauke-t480:~/openwrt/openwrt$ ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm -n build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' |sort |head -5 __ksymtab___ablkcipher_walk_complete __ksymtab_ablkcipher_walk_done __ksymtab_ablkcipher_walk_phys __ksymtab_abort __ksymtab_abort_creds ---------------------------- I build the kernel with this configuration: hauke@hauke-t480:~/openwrt/openwrt$ ./scripts/diffconfig.sh CONFIG_TARGET_ipq40xx=y CONFIG_TARGET_ipq40xx_generic=y CONFIG_TARGET_ipq40xx_generic_DEVICE_avm_fritzbox-7530=y hauke@hauke-t480:~/openwrt/openwrt$ Hauke
Hi, Hauke, On Thu, 31 Dec 2020 at 19:07, Hauke Mehrtens <hauke@hauke-m.de> wrote: > > Hi, > > On the ipq40xx target the results of both commands are different. The > original command removed the __ksymtab_ prefix, you do not remove it. > > Original result: > ---------------------------- > hauke@hauke-t480:~/openwrt/openwrt$ > ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm > -n > build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o > | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' |sort > |head -5 > __ablkcipher_walk_complete > ablkcipher_walk_done > ablkcipher_walk_phys > abort > abort_creds > ---------------------------- > > Result with your change: > ---------------------------- > hauke@hauke-t480:~/openwrt/openwrt$ > ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm > -n > build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o > | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' |sort |head -5 > __ksymtab___ablkcipher_walk_complete > __ksymtab_ablkcipher_walk_done > __ksymtab_ablkcipher_walk_phys > __ksymtab_abort > __ksymtab_abort_creds > ---------------------------- Hm… strange. The substr should have taken care of it, I wonder what I've missed. Anyway, thanks for the heads-up, I'm going to fix and respin. > I build the kernel with this configuration: > > hauke@hauke-t480:~/openwrt/openwrt$ ./scripts/diffconfig.sh > CONFIG_TARGET_ipq40xx=y > CONFIG_TARGET_ipq40xx_generic=y > CONFIG_TARGET_ipq40xx_generic_DEVICE_avm_fritzbox-7530=y > hauke@hauke-t480:~/openwrt/openwrt$ Thanks, Rui
Hi again, On Thu, 31 Dec 2020 at 19:30, Rui Salvaterra <rsalvaterra@gmail.com> wrote: > > On Thu, 31 Dec 2020 at 19:07, Hauke Mehrtens <hauke@hauke-m.de> wrote: > > > > Result with your change: > > ---------------------------- > > hauke@hauke-t480:~/openwrt/openwrt$ > > ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm > > -n > > build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o > > | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' |sort |head -5 > > __ksymtab___ablkcipher_walk_complete > > __ksymtab_ablkcipher_walk_done > > __ksymtab_ablkcipher_walk_phys > > __ksymtab_abort > > __ksymtab_abort_creds > > ---------------------------- > > Hm… strange. The substr should have taken care of it, I wonder what I've missed. > Anyway, thanks for the heads-up, I'm going to fix and respin. Ok, I see the problem. You're executing it in the terminal and not removing the makefile escaping from the awk script. Try $3 instead of $$$$3. Thanks, Rui
On 12/31/20 8:38 PM, Rui Salvaterra wrote: > Hi again, > > On Thu, 31 Dec 2020 at 19:30, Rui Salvaterra <rsalvaterra@gmail.com> wrote: >> >> On Thu, 31 Dec 2020 at 19:07, Hauke Mehrtens <hauke@hauke-m.de> wrote: >>> >>> Result with your change: >>> ---------------------------- >>> hauke@hauke-t480:~/openwrt/openwrt$ >>> ./staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-8.4.0_musl_eabi/bin/arm-openwrt-linux-nm >>> -n >>> build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-ipq40xx_generic/linux-5.4.85/vmlinux.o >>> | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' |sort |head -5 >>> __ksymtab___ablkcipher_walk_complete >>> __ksymtab_ablkcipher_walk_done >>> __ksymtab_ablkcipher_walk_phys >>> __ksymtab_abort >>> __ksymtab_abort_creds >>> ---------------------------- >> >> Hm… strange. The substr should have taken care of it, I wonder what I've missed. >> Anyway, thanks for the heads-up, I'm going to fix and respin. > > Ok, I see the problem. You're executing it in the terminal and not > removing the makefile escaping from the awk script. Try $3 instead of > $$$$3. Hi Rui, Yes you are right, when I use this correctly it starts to work. ;-) Hauke
diff --git a/include/kernel-build.mk b/include/kernel-build.mk index 22f7c4c7c7..6123c9d456 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -105,7 +105,7 @@ define BuildKernel xargs $(TARGET_CROSS)nm | \ awk '$$$$1 == "U" { print $$$$2 } ' | \ sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt - $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt + $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | awk '/^[0-9a-f]+ [rR] __ksymtab_/ {print substr($$$$3,11)}' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt ( \
While parsing the nm output, we need to account for the fact that 64-bit kernels have 64-bit wide addresses. While at it, replace the grep | sed combo with a single awk invocation and a stronger regex. Fixes: 2ef0acc5fcda557fa5aaad35d27cb8cf75be96d2 "kernel-build: fix STRIP_KERNEL_EXPORTS for recent kernels" Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com> --- include/kernel-build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)