ARM: Eliminate decompressor -Dstatic= PIC hack
We used to build decompressors with -Dstatic= to avoid any local data
being generated. The problem is that local data generates GOTOFF
relocations, which means we can't relocate the data relative to the
text segment.
Global data, on the other hand, goes through the GOT, and can be
relocated anywhere.
Unfortunately, with the new decompressors, this presents a problem
since they declare static data within functions, and this leads to
stack overflow.
Fix this by separating out the decompressor code into a separate file,
and removing 'static' from BSS data in misc.c.
Also, discard the .data section - this means that should we end up
with read/write initialized data, the decompressor will fail to link
and the problem will be obvious.
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-02-25 12:14:40 +00:00
|
|
|
#define _LINUX_STRING_H_
|
|
|
|
|
|
|
|
#include <linux/compiler.h> /* for inline */
|
|
|
|
#include <linux/types.h> /* for size_t */
|
|
|
|
#include <linux/stddef.h> /* for NULL */
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/string.h>
|
|
|
|
|
|
|
|
extern unsigned long free_mem_ptr;
|
|
|
|
extern unsigned long free_mem_end_ptr;
|
|
|
|
extern void error(char *);
|
|
|
|
|
|
|
|
#define STATIC static
|
2010-03-15 14:29:22 +00:00
|
|
|
#define STATIC_RW_DATA /* non-static please */
|
ARM: Eliminate decompressor -Dstatic= PIC hack
We used to build decompressors with -Dstatic= to avoid any local data
being generated. The problem is that local data generates GOTOFF
relocations, which means we can't relocate the data relative to the
text segment.
Global data, on the other hand, goes through the GOT, and can be
relocated anywhere.
Unfortunately, with the new decompressors, this presents a problem
since they declare static data within functions, and this leads to
stack overflow.
Fix this by separating out the decompressor code into a separate file,
and removing 'static' from BSS data in misc.c.
Also, discard the .data section - this means that should we end up
with read/write initialized data, the decompressor will fail to link
and the problem will be obvious.
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-02-25 12:14:40 +00:00
|
|
|
|
|
|
|
/* Diagnostic functions */
|
|
|
|
#ifdef DEBUG
|
|
|
|
# define Assert(cond,msg) {if(!(cond)) error(msg);}
|
|
|
|
# define Trace(x) fprintf x
|
|
|
|
# define Tracev(x) {if (verbose) fprintf x ;}
|
|
|
|
# define Tracevv(x) {if (verbose>1) fprintf x ;}
|
|
|
|
# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
|
|
|
|
# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
|
|
|
|
#else
|
|
|
|
# define Assert(cond,msg)
|
|
|
|
# define Trace(x)
|
|
|
|
# define Tracev(x)
|
|
|
|
# define Tracevv(x)
|
|
|
|
# define Tracec(c,x)
|
|
|
|
# define Tracecv(c,x)
|
|
|
|
#endif
|
|
|
|
|
2012-08-15 15:28:36 +00:00
|
|
|
/* Not needed, but used in some headers pulled in by decompressors */
|
|
|
|
extern char * strstr(const char * s1, const char *s2);
|
|
|
|
|
ARM: Eliminate decompressor -Dstatic= PIC hack
We used to build decompressors with -Dstatic= to avoid any local data
being generated. The problem is that local data generates GOTOFF
relocations, which means we can't relocate the data relative to the
text segment.
Global data, on the other hand, goes through the GOT, and can be
relocated anywhere.
Unfortunately, with the new decompressors, this presents a problem
since they declare static data within functions, and this leads to
stack overflow.
Fix this by separating out the decompressor code into a separate file,
and removing 'static' from BSS data in misc.c.
Also, discard the .data section - this means that should we end up
with read/write initialized data, the decompressor will fail to link
and the problem will be obvious.
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-02-25 12:14:40 +00:00
|
|
|
#ifdef CONFIG_KERNEL_GZIP
|
|
|
|
#include "../../../../lib/decompress_inflate.c"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_KERNEL_LZO
|
|
|
|
#include "../../../../lib/decompress_unlzo.c"
|
|
|
|
#endif
|
|
|
|
|
2010-04-03 10:40:28 +00:00
|
|
|
#ifdef CONFIG_KERNEL_LZMA
|
|
|
|
#include "../../../../lib/decompress_unlzma.c"
|
|
|
|
#endif
|
|
|
|
|
2012-01-26 12:08:57 +00:00
|
|
|
#ifdef CONFIG_KERNEL_XZ
|
|
|
|
#define memmove memmove
|
|
|
|
#define memcpy memcpy
|
|
|
|
#include "../../../../lib/decompress_unxz.c"
|
|
|
|
#endif
|
|
|
|
|
2013-07-08 23:01:48 +00:00
|
|
|
#ifdef CONFIG_KERNEL_LZ4
|
|
|
|
#include "../../../../lib/decompress_unlz4.c"
|
|
|
|
#endif
|
|
|
|
|
2011-04-22 01:59:49 +00:00
|
|
|
int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
|
ARM: Eliminate decompressor -Dstatic= PIC hack
We used to build decompressors with -Dstatic= to avoid any local data
being generated. The problem is that local data generates GOTOFF
relocations, which means we can't relocate the data relative to the
text segment.
Global data, on the other hand, goes through the GOT, and can be
relocated anywhere.
Unfortunately, with the new decompressors, this presents a problem
since they declare static data within functions, and this leads to
stack overflow.
Fix this by separating out the decompressor code into a separate file,
and removing 'static' from BSS data in misc.c.
Also, discard the .data section - this means that should we end up
with read/write initialized data, the decompressor will fail to link
and the problem will be obvious.
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-02-25 12:14:40 +00:00
|
|
|
{
|
2015-09-09 22:39:12 +00:00
|
|
|
return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
|
ARM: Eliminate decompressor -Dstatic= PIC hack
We used to build decompressors with -Dstatic= to avoid any local data
being generated. The problem is that local data generates GOTOFF
relocations, which means we can't relocate the data relative to the
text segment.
Global data, on the other hand, goes through the GOT, and can be
relocated anywhere.
Unfortunately, with the new decompressors, this presents a problem
since they declare static data within functions, and this leads to
stack overflow.
Fix this by separating out the decompressor code into a separate file,
and removing 'static' from BSS data in misc.c.
Also, discard the .data section - this means that should we end up
with read/write initialized data, the decompressor will fail to link
and the problem will be obvious.
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-02-25 12:14:40 +00:00
|
|
|
}
|