Skip to contentSkip to conversation

mips: always link byteswap helpers into decompressor

PATCH Applied Arnd Bergmann 2 participants 2 messages Jul 2, 2021 – Jul 5, 2021 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: always link byteswap helpers into decompressor

From: Arnd Bergmann <[email protected]>

My series to clean up the unaligned access implementation across architectures caused some mips randconfig builds to fail with:

mips64-linux-ld: arch/mips/boot/compressed/decompress.o: in function `decompress_kernel':
decompress.c:(.text.decompress_kernel+0x54): undefined reference to `__bswapsi2'

It turns out that this problem has already been fixed for the XZ decompressor but now it also shows up in (at least) LZO and LZ4. From my analysis I concluded that the compiler could always have emitted those calls, but the different implementation allowed it to make otherwise better decisions about not inlining the byteswap, which results in the link error when the out-of-line code is missing.

While it could be addressed by adding it to the two decompressor implementations that are known to be affected, but as this only adds 112 bytes to the kernel, the safer choice is to always add them.

Fixes c50ec6787536 ("MIPS: zboot: Fix the build with XZ compression on older GCC versions")
Fixes 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
---
 arch/mips/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/boot/compressed/Makefile +2 -2
index e4b7839293e1..3548b3b45269 100644
@@ -40,7 +40,7 @@ GCOV_PROFILE := n
 UBSAN_SANITIZE := n
 
 # decompressor objects (linked with vmlinuz)
-vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
+vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
 
 ifdef CONFIG_DEBUG_ZBOOT
 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)		   += $(obj)/dbg.o
@@ -54,7 +54,7 @@ extra-y += uart-ath79.c
 $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
 	$(call cmd,shipped)
 
-vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
+vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
 
 extra-y += ashldi3.c
 $(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE
Signature · 1 line
2.29.2
maintainer Applied
#1 lore raw
Quoted 27 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

My series to clean up the unaligned access implementation across architectures caused some mips randconfig builds to fail with:

mips64-linux-ld: arch/mips/boot/compressed/decompress.o: in function `decompress_kernel':

   decompress.c:(.text.decompress_kernel+0x54): undefined reference to `__bswapsi2'

It turns out that this problem has already been fixed for the XZ decompressor but now it also shows up in (at least) LZO and LZ4. From my analysis I concluded that the compiler could always have emitted those calls, but the different implementation allowed it to make otherwise better decisions about not inlining the byteswap, which results in the link error when the out-of-line code is missing.

While it could be addressed by adding it to the two decompressor implementations that are known to be affected, but as this only adds 112 bytes to the kernel, the safer choice is to always add them.

Fixes c50ec6787536 ("MIPS: zboot: Fix the build with XZ compression on older GCC versions")
Fixes 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
Quoted 3 lines
---
 arch/mips/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-next (for second pull request).

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]