move more kernel decompression bits to .init.* sections
PATCH 3/3 move more kernel decompression bits to .init.* sections
Based on how c/s 22986:076b63b74cf6 changed xen/libelf/Makefile I suppose this is compatibile with those clang/llvm changes, but I didn't actually test it.
Signed-off-by Jan Beulich <[email protected]>
xen/Rules.mk +12 -0
@@ -152,6 +152,18 @@ _clean_%/: FORCE %.o: %.S Makefile $(CC) $(AFLAGS) -c $< -o $@ +SPECIAL_DATA_SECTIONS := rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) \ + $(foreach r,rel rel.ro,data.$(r) data.$(r).local) + +%.init.o: %.o Makefile + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p}' | while read idx name sz rest; do \ + case "$$name" in \ + .text|.data|.bss) test $$sz = 0 || \ + { echo "Error: size of $<:$$name is 0x$$sz" >&2; exit $$idx; };; \ + esac; \ + done + $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ + %.i: %.c Makefile $(CPP) $(CFLAGS) $< -o $@
xen/arch/x86/Makefile +1 -1
@@ -10,6 +10,7 @@ subdir-$(x86_64) += x86_64 obj-y += apic.o obj-y += bitops.o +obj-bin-y += bzimage.init.o obj-bin-y += clear_page.o obj-bin-y += copy_page.o obj-y += compat.o
@@ -55,7 +56,6 @@ obj-y += machine_kexec.o obj-y += crash.o obj-y += tboot.o obj-y += hpet.o -obj-y += bzimage.o obj-$(crash_debug) += gdbstub.o
xen/arch/x86/bzimage.c +10 -9
@@ -9,21 +9,21 @@#define HEAPORDER 3 -static unsigned char *window; +static unsigned char *__initdata window;#define memptr long -static memptr free_mem_ptr; -static memptr free_mem_end_ptr; +static memptr __initdata free_mem_ptr; +static memptr __initdata free_mem_end_ptr;#define WSIZE 0x80000000 -static unsigned char *inbuf; -static unsigned insize; +static unsigned char *__initdata inbuf; +static unsigned __initdata insize;/* Index of next byte to be processed in inbuf: */ -static unsigned inptr; +static unsigned __initdata inptr;/* Bytes in output buffer: */ -static unsigned outcnt; +static unsigned __initdata outcnt;#define OF (args) args#define STATIC static
@@ -34,7 +34,8 @@ typedef unsigned char uch;typedef unsigned short ush ;typedef unsigned long ulg ; -#define INIT __init +#define INIT __init +#define INITDATA __initdata#define get_byte () (inptr < insize ? inbuf[inptr++] : fill_inbuf())
@@ -55,7 +56,7 @@ typedef unsigned long ulg;# define Tracecv (c, x)#endif -static long bytes_out; +static long __initdata bytes_out;static void flush_window (void );static __init void error (char *x)
xen/common/Makefile +1 -1
@@ -43,7 +43,7 @@ obj-y += radix-tree.o obj-y += rbtree.o obj-y += lzo.o -obj-$(CONFIG_X86) += decompress.o bunzip2.o unxz.o unlzma.o unlzo.o +obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo,$(n).init.o) obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o
xen/common/inflate.c +10 -9
@@ -120,6 +120,7 @@ static char rcsid[] = "#Id: inflate.c,v#ifndef INIT #define INIT +#define INITDATA #endif #define slide window
@@ -216,8 +217,8 @@ static const ush cpdext[] = { /*the stream. */ -STATIC ulg bb; /* bit buffer */ -STATIC unsigned bk;/* bits in bit buffer */ +STATIC ulg INITDATA bb; /* bit buffer */ +STATIC unsigned INITDATA bk; /* bits in bit buffer */ STATIC const ush mask_bits[] = {0x0000 ,
@@ -234,10 +235,10 @@ STATIC const ush mask_bits[] = {* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 */ -static unsigned long malloc_ptr; -static int malloc_count; +static unsigned long INITDATA malloc_ptr; +static int INITDATA malloc_count; -static void *malloc (int size) +static void *INIT malloc(int size) {void *p;
@@ -258,7 +259,7 @@ static void *malloc(int size)return p; } -static void free (void *where) +static void INIT free(void *where) { malloc_count--;if (!malloc_count)
@@ -311,7 +312,7 @@ STATIC const int dbits = 6; /*#define N_MAX 288/* maximum number of codes in any set */ -STATIC unsigned hufts;/* track memory usage */ +STATIC unsigned INITDATA hufts; /* track memory usage */ STATIC int INIT huft_build(
@@ -1129,8 +1130,8 @@ STATIC int INIT inflate(void)* **********************************************************************/ -static ulg crc_32_tab[256 ]; -static ulg crc;/* initialized in makecrc() so it'll reside in bss */ +static ulg INITDATA crc_32_tab[256]; +static ulg INITDATA crc; /* initialized in makecrc() so it'll reside in bss */#define CRC_VALUE (crc ^ 0xffffffffUL)/*
xen/common/libelf/Makefile +1 -1
@@ -1,6 +1,6 @@ obj-bin-y := libelf.o -SECTIONS := text data rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) $(foreach r,rel rel.ro,data.$(r) data.$(r).local) +SECTIONS := text data $(SPECIAL_DATA_SECTIONS) libelf.o: libelf-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
xen/common/unlzma.c +1 -1
@@ -75,7 +75,7 @@ struct rc {#define RC_MODEL_TOTAL_BITS 11 -static int nofill (void *buffer,unsigned int len) +static int INIT nofill(void *buffer, unsigned int len) {return -1 ; }
xen/common/xz/dec_bcj.c +2 -3
@@ -87,11 +87,10 @@ static inline int INIT bcj_x86_test_msby static size_t INIT bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { - static /*const*/ bool_t INITDATA mask_to_allowed_status[8] +static const bool_t mask_to_allowed_status[8 ] = { true, true, true, false, true, false, false, false }; - static /*const*/ uint8_t INITDATA mask_to_bit_num[8] - = {0 ,1 ,2 ,2 ,3 ,3 ,3 ,3 }; +static const uint8_t mask_to_bit_num[8 ] = {0 ,1 ,2 ,2 ,3 ,3 ,3 ,3 };size_t i;size_t prev_pos = (size_t )-1 ;
Based on how c/s 22986:076b63b74cf6 changed xen/libelf/Makefile I suppose this is compatibile with those clang/llvm changes, but I didn't actually test it.
Signed-off-by Jan Beulich <[email protected]>
xen/Rules.mk +12 -0
@@ -152,6 +152,18 @@ _clean_%/: FORCE %.o: %.S Makefile $(CC) $(AFLAGS) -c $< -o $@ +SPECIAL_DATA_SECTIONS := rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) \ + $(foreach r,rel rel.ro,data.$(r) data.$(r).local) + +%.init.o: %.o Makefile + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p}' | while read idx name sz rest; do \ + case "$$name" in \ + .text|.data|.bss) test $$sz = 0 || \ + { echo "Error: size of $<:$$name is 0x$$sz" >&2; exit $$idx; };; \ + esac; \ + done + $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ + %.i: %.c Makefile $(CPP) $(CFLAGS) $< -o $@
xen/arch/x86/Makefile +1 -1
@@ -10,6 +10,7 @@ subdir-$(x86_64) += x86_64 obj-y += apic.o obj-y += bitops.o +obj-bin-y += bzimage.init.o obj-bin-y += clear_page.o obj-bin-y += copy_page.o obj-y += compat.o
@@ -55,7 +56,6 @@ obj-y += machine_kexec.o obj-y += crash.o obj-y += tboot.o obj-y += hpet.o -obj-y += bzimage.o obj-$(crash_debug) += gdbstub.o
xen/arch/x86/bzimage.c +10 -9
@@ -9,21 +9,21 @@#define HEAPORDER 3 -static unsigned char *window; +static unsigned char *__initdata window;#define memptr long -static memptr free_mem_ptr; -static memptr free_mem_end_ptr; +static memptr __initdata free_mem_ptr; +static memptr __initdata free_mem_end_ptr;#define WSIZE 0x80000000 -static unsigned char *inbuf; -static unsigned insize; +static unsigned char *__initdata inbuf; +static unsigned __initdata insize;/* Index of next byte to be processed in inbuf: */ -static unsigned inptr; +static unsigned __initdata inptr;/* Bytes in output buffer: */ -static unsigned outcnt; +static unsigned __initdata outcnt;#define OF (args) args#define STATIC static
@@ -34,7 +34,8 @@ typedef unsigned char uch;typedef unsigned short ush ;typedef unsigned long ulg ; -#define INIT __init +#define INIT __init +#define INITDATA __initdata#define get_byte () (inptr < insize ? inbuf[inptr++] : fill_inbuf())
@@ -55,7 +56,7 @@ typedef unsigned long ulg;# define Tracecv (c, x)#endif -static long bytes_out; +static long __initdata bytes_out;static void flush_window (void );static __init void error (char *x)
xen/common/Makefile +1 -1
@@ -43,7 +43,7 @@ obj-y += radix-tree.o obj-y += rbtree.o obj-y += lzo.o -obj-$(CONFIG_X86) += decompress.o bunzip2.o unxz.o unlzma.o unlzo.o +obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo,$(n).init.o) obj-$(perfc) += perfc.o obj-$(crash_debug) += gdbstub.o
xen/common/inflate.c +10 -9
@@ -120,6 +120,7 @@ static char rcsid[] = "#Id: inflate.c,v#ifndef INIT #define INIT +#define INITDATA #endif #define slide window
@@ -216,8 +217,8 @@ static const ush cpdext[] = { /*the stream. */ -STATIC ulg bb; /* bit buffer */ -STATIC unsigned bk;/* bits in bit buffer */ +STATIC ulg INITDATA bb; /* bit buffer */ +STATIC unsigned INITDATA bk; /* bits in bit buffer */ STATIC const ush mask_bits[] = {0x0000 ,
@@ -234,10 +235,10 @@ STATIC const ush mask_bits[] = {* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 */ -static unsigned long malloc_ptr; -static int malloc_count; +static unsigned long INITDATA malloc_ptr; +static int INITDATA malloc_count; -static void *malloc (int size) +static void *INIT malloc(int size) {void *p;
@@ -258,7 +259,7 @@ static void *malloc(int size)return p; } -static void free (void *where) +static void INIT free(void *where) { malloc_count--;if (!malloc_count)
@@ -311,7 +312,7 @@ STATIC const int dbits = 6; /*#define N_MAX 288/* maximum number of codes in any set */ -STATIC unsigned hufts;/* track memory usage */ +STATIC unsigned INITDATA hufts; /* track memory usage */ STATIC int INIT huft_build(
@@ -1129,8 +1130,8 @@ STATIC int INIT inflate(void)* **********************************************************************/ -static ulg crc_32_tab[256 ]; -static ulg crc;/* initialized in makecrc() so it'll reside in bss */ +static ulg INITDATA crc_32_tab[256]; +static ulg INITDATA crc; /* initialized in makecrc() so it'll reside in bss */#define CRC_VALUE (crc ^ 0xffffffffUL)/*
xen/common/libelf/Makefile +1 -1
@@ -1,6 +1,6 @@ obj-bin-y := libelf.o -SECTIONS := text data rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) $(foreach r,rel rel.ro,data.$(r) data.$(r).local) +SECTIONS := text data $(SPECIAL_DATA_SECTIONS) libelf.o: libelf-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
xen/common/unlzma.c +1 -1
@@ -75,7 +75,7 @@ struct rc {#define RC_MODEL_TOTAL_BITS 11 -static int nofill (void *buffer,unsigned int len) +static int INIT nofill(void *buffer, unsigned int len) {return -1 ; }
xen/common/xz/dec_bcj.c +2 -3
@@ -87,11 +87,10 @@ static inline int INIT bcj_x86_test_msby static size_t INIT bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { - static /*const*/ bool_t INITDATA mask_to_allowed_status[8] +static const bool_t mask_to_allowed_status[8 ] = { true, true, true, false, true, false, false, false }; - static /*const*/ uint8_t INITDATA mask_to_bit_num[8] - = {0 ,1 ,2 ,2 ,3 ,3 ,3 ,3 }; +static const uint8_t mask_to_bit_num[8 ] = {0 ,1 ,2 ,2 ,3 ,3 ,3 ,3 };size_t i;size_t prev_pos = (size_t )-1 ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel