lz4: fix KERNEL_LZ4 support
PATCH 1/1 lz4: fix KERNEL_LZ4 support
The updated lz4 library removed the #ifdef guards around the various EXPORT_SYMBOL statements in the original kernel lz4 support, which broke CONFIG_KERNEL_LZ4 on x86:
x86_64-linux-ld: -r and -pie may not be used together scripts/Makefile.build:308: recipe for target 'arch/x86/boot/compressed/misc.o' failed
This uses a simpler way to do the same thing, by overriding the EXPORT_SYMBOL macro.
--- lib/lz4/lz4_decompress.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/lz4/lz4_decompress.c +5 -0
@@ -40,6 +40,11 @@#include <linux/kernel.h> #include <asm/unaligned.h> +#ifdef STATIC +#undef EXPORT_SYMBOL +#define EXPORT_SYMBOL (x) +#endif +/*-***************************** * Decompression functions *******************************/
Signature · 1 line
2.9.0
Quoted 10 lines · On Wed, 8 Feb 2017 22:19:23 +0100 Arnd Bergmann <[email protected]> wrote:
The updated lz4 library removed the #ifdef guards around the various
EXPORT_SYMBOLstatements in the original kernel lz4 support, which brokeCONFIG_KERNEL_LZ4on x86:x86_64-linux-ld: -r and -pie may not be used together
scripts/Makefile.build:308: recipe for target 'arch/x86/boot/compressed/misc.o' failedThis uses a simpler way to do the same thing, by overriding the
EXPORT_SYMBOLmacro.
hm, why does this CONFIG_KERNEL_LZ4 thing exist? What makes lz4 different from a billion other kernel modules?
lib/lz4/lz4_decompress.c line 47
Quoted 12 lines
index
9bf918233749..a390f63bc475100644lib/lz4/lz4_decompress.c +5
-0@@ -40,6 +40,11 @@#include <linux/kernel.h> #include <asm/unaligned.h> +#ifdef STATIC +#undef EXPORT_SYMBOL +#define EXPORT_SYMBOL (x) +#endif +
That is a bit hacky, and somewhat "surprising". Why not do it the old fashioned way?
lib/lz4/lz4_decompress.c renamed from lib/lz4/lz4_decompress.c~lz4-fix-kernel_lz4-support-fix +10 -7
@@ -328,7 +323,6 @@ int LZ4_decompress_safe(const char *sour maxDecompressedSize, endOnInputSize, full,0 , noDict, (BYTE *)dest, NULL, 0); } -EXPORT_SYMBOL (LZ4_decompress_safe);int LZ4_decompress_safe_partial (const char *source,char *dest,int compressedSize,int targetOutputSize,int maxDecompressedSize)
@@ -337,7 +331,6 @@ int LZ4_decompress_safe_partial(const ch maxDecompressedSize, endOnInputSize, partial, targetOutputSize, noDict, (BYTE *)dest, NULL, 0); } -EXPORT_SYMBOL (LZ4_decompress_safe_partial);int LZ4_decompress_fast (const char *source,char *dest,int originalSize) {
@@ -345,7 +338,6 @@ int LZ4_decompress_fast(const char *sour endOnOutputSize, full,0 , withPrefix64k, (BYTE *)(dest - 64 * KB), NULL, 64 * KB); } -EXPORT_SYMBOL (LZ4_decompress_fast);int LZ4_setStreamDecode (LZ4_streamDecode_t *LZ4_streamDecode,const char *dictionary,int dictSize)
@@ -358,7 +350,6 @@ int LZ4_setStreamDecode(LZ4_streamDecode lz4sd->extDictSize =0 ;return 1 ; } -EXPORT_SYMBOL (LZ4_setStreamDecode);/* * *_continue() :
@@ -406,7 +397,6 @@ int LZ4_decompress_safe_continue(LZ4_strreturn result; } -EXPORT_SYMBOL (LZ4_decompress_safe_continue);int LZ4_decompress_fast_continue (LZ4_streamDecode_t *LZ4_streamDecode,const char *source,char *dest,int originalSize)
@@ -441,7 +431,6 @@ int LZ4_decompress_fast_continue(LZ4_strreturn result; } -EXPORT_SYMBOL (LZ4_decompress_fast_continue);/* * Advanced decoding functions :
@@ -478,7 +467,6 @@ int LZ4_decompress_safe_usingDict(constreturn LZ4_decompress_usingDict_generic (source, dest, compressedSize, maxOutputSize,1 , dictStart, dictSize); } -EXPORT_SYMBOL (LZ4_decompress_safe_usingDict);int LZ4_decompress_fast_usingDict (const char *source,char *dest,int originalSize,const char *dictStart,int dictSize)
@@ -486,7 +474,17 @@ int LZ4_decompress_fast_usingDict(constreturn LZ4_decompress_usingDict_generic (source, dest,0 , originalSize,0 , dictStart, dictSize); } + +#ifndef STATIC +EXPORT_SYMBOL (LZ4_decompress_safe); +EXPORT_SYMBOL (LZ4_decompress_safe_partial); +EXPORT_SYMBOL (LZ4_decompress_fast); +EXPORT_SYMBOL (LZ4_setStreamDecode); +EXPORT_SYMBOL (LZ4_decompress_safe_continue); +EXPORT_SYMBOL (LZ4_decompress_fast_continue); +EXPORT_SYMBOL (LZ4_decompress_safe_usingDict);EXPORT_SYMBOL (LZ4_decompress_fast_usingDict); +#endif MODULE_LICENSE ("Dual BSD/GPL" );MODULE_DESCRIPTION ("LZ4 decompressor" );
_
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Wed, 8 Feb 2017 22:19:23 +0100 Arnd Bergmann <[email protected]> wrote:
The updated lz4 library removed the #ifdef guards around the various
EXPORT_SYMBOLstatements in the original kernel lz4 support, which brokeCONFIG_KERNEL_LZ4on x86:x86_64-linux-ld: -r and -pie may not be used together
scripts/Makefile.build:308: recipe for target 'arch/x86/boot/compressed/misc.o' failed
Quoted 6 lines
Quoted 3 lines
This uses a simpler way to do the same thing, by overriding the
EXPORT_SYMBOLmacro.hm, why does this
CONFIG_KERNEL_LZ4thing exist? What makes lz4 different from a billion other kernel modules?
This symbol means the kernel (bzImage) itself is compressed with lz4, an we include the lz4_decompress.c code from arch/x86/boot/compressed/misc.c
Quoted 7 lines
Quoted 7 lines
index
9bf918233749..a390f63bc475100644lib/lz4/lz4_decompress.c +0
-0@@ -40,6 +40,11 @@#include <linux/kernel.h> #include <asm/unaligned.h>
Quoted 8 lines
lib/lz4/lz4_decompress.c line 47
Quoted 5 lines
lib/lz4/lz4_decompress.c +5
-0+#ifdef STATIC +#undef EXPORT_SYMBOL +#define EXPORT_SYMBOL (x) +#endif +That is a bit hacky, and somewhat "surprising". Why not do it the old fashioned way?
I was trying to keep the modification small, to simplify adding it the next time we update the lz4 library.
lib/lz4/lz4_decompress.c int LZ4_decompress_fast_usingDict(const · line 487
Quoted 12 lines
lib/lz4/lz4_decompress.c renamed from lib/lz4/lz4_decompress.c~lz4-fix-kernel_lz4-support-fix +10
-0+ +#ifndef STATIC +EXPORT_SYMBOL (LZ4_decompress_safe); +EXPORT_SYMBOL (LZ4_decompress_safe_partial); +EXPORT_SYMBOL (LZ4_decompress_fast); +EXPORT_SYMBOL (LZ4_setStreamDecode); +EXPORT_SYMBOL (LZ4_decompress_safe_continue); +EXPORT_SYMBOL (LZ4_decompress_fast_continue); +EXPORT_SYMBOL (LZ4_decompress_safe_usingDict);EXPORT_SYMBOL (LZ4_decompress_fast_usingDict); +#endif
This seems fine too, but then we probably want to keep the #ifndef around the MODULE_LICENSE()/MODULE_DESCRIPTION() macros as well, like we do in the other decompressors that we can use for boot image.
lib/inflate.c also marks all functions as STATIC, but the other algorithms don't, so I'm not sure whether we should do the same here.
Arnd
Hello,
Quoted 57 lines · Arnd Bergmann
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Wed, 8 Feb 2017 22:19:23 +0100 Arnd Bergmann <[email protected]> wrote:
The updated lz4 library removed the #ifdef guards around the various
EXPORT_SYMBOLstatements in the original kernel lz4 support, which brokeCONFIG_KERNEL_LZ4on x86:x86_64-linux-ld: -r and -pie may not be used together
scripts/Makefile.build:308: recipe for target 'arch/x86/boot/compressed/misc.o' failedQuoted 6 lines
Quoted 3 lines
This uses a simpler way to do the same thing, by overriding the
EXPORT_SYMBOLmacro.hm, why does this
CONFIG_KERNEL_LZ4thing exist? What makes lz4 different from a billion other kernel modules?This symbol means the kernel (bzImage) itself is compressed with lz4, an we include the
lz4_decompress.ccode fromarch/x86/boot/compressed/misc.cQuoted 7 lines
Quoted 7 lines
index
9bf918233749..a390f63bc475100644lib/lz4/lz4_decompress.c +0
-0@@ -40,6 +40,11 @@#include <linux/kernel.h> #include <asm/unaligned.h> Quoted 8 lines
lib/lz4/lz4_decompress.c line 47
Quoted 5 lines
lib/lz4/lz4_decompress.c +5
-0+#ifdef STATIC +#undef EXPORT_SYMBOL +#define EXPORT_SYMBOL (x) +#endif +That is a bit hacky, and somewhat "surprising". Why not do it the old fashioned way?
I was trying to keep the modification small, to simplify adding it the next time we update the lz4 library.
lib/lz4/lz4_decompress.c int LZ4_decompress_fast_usingDict(const · line 487
Quoted 12 lines
lib/lz4/lz4_decompress.c renamed from lib/lz4/lz4_decompress.c~lz4-fix-kernel_lz4-support-fix +10
-0+ +#ifndef STATIC +EXPORT_SYMBOL (LZ4_decompress_safe); +EXPORT_SYMBOL (LZ4_decompress_safe_partial); +EXPORT_SYMBOL (LZ4_decompress_fast); +EXPORT_SYMBOL (LZ4_setStreamDecode); +EXPORT_SYMBOL (LZ4_decompress_safe_continue); +EXPORT_SYMBOL (LZ4_decompress_fast_continue); +EXPORT_SYMBOL (LZ4_decompress_safe_usingDict);EXPORT_SYMBOL (LZ4_decompress_fast_usingDict); +#endif This seems fine too, but then we probably want to keep the #ifndef around the MODULE_LICENSE()/MODULE_DESCRIPTION() macros as well, like we do in the other decompressors that we can use for boot image.
Quoted 4 lines
lib/inflate.calso marks all functions as STATIC, but the other algorithms don't, so I'm not sure whether we should do the same here.Arnd
this looks reasonable for me.
Andrew: What is the usual way of dealing with such fixes? Since there's some feedback left, would I include it directly in my patchseries?
Thanks,
Sven