Skip to contentSkip to conversation

boot time inflation code hack

PATCH Takehiro Tominaga 1 participant 1 message Sep 11, 2001

lore
Share & tools
lore
#0 lore raw

hi all,

On some architectures, linux kernel image can be stored in compressed format(with gzip) and boot loader will inflate the compression.

I found linux/lib/inflate.c is the boot-time inflating routine and is not used from another part of kernel. In the inflate.c, there are some malloc() and free().

inflate.c is included from linux/arch/*/boot/compressed/misc.c, which provides these functions.

but, for each architecture, free() does nothing at all. So we can remove some part of inflate.c. the patch is attached.

I just tested it on IA32 platform only. please review on your architecture.
---
Takehiro TOMINAGA // may the source be with you!

inflate.c renamed from inflate.c.bak +11 -2
@@ -140,7 +140,11 @@
 /* Function prototypes */
 STATIC int huft_build OF((unsigned *, unsigned, unsigned, 
 		const ush *, const ush *, struct huft **, int *));
-STATIC int huft_free OF((struct huft *));
+#ifdef SOMETHINGINFREE
+ STATIC int huft_free OF((struct huft *));
+#else
+ #define huft_free(dummy) 0
+#endif
 STATIC int inflate_codes OF((struct huft *, struct huft *, int, int));
 STATIC int inflate_stored OF((void));
 STATIC int inflate_fixed OF((void));
@@ -489,6 +493,7 @@
 
 
 
+#ifdef SOMETHINGINFREE
 STATIC int huft_free(t)
 struct huft *t;         /* table to free */
 /* Free the malloc'ed tables built by huft_build(), which makes a linked
@@ -508,7 +513,7 @@
   } 
   return 0;
 }
-
+#endif
 
 STATIC int inflate_codes(tl, td, bl, bd)
 struct huft *tl, *td;   /* literal/length and distance decoder tables */
@@ -1026,6 +1031,7 @@
   int i;                /* counter for all possible eight bit values */
   int k;                /* byte being shifted into crc apparatus */
 
+#if 0
   /* terms of polynomial defining this crc (except x^32): */
   static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
 
@@ -1033,6 +1039,9 @@
   e = 0;
   for (i = 0; i < sizeof(p)/sizeof(int); i++)
     e |= 1L << (31 - p[i]);
+#else
+  e = 0xedb88320;
+#endif
 
   crc_32_tab[0] = 0;