From: "Jan Beulich" Subject: [PATCH 3/3] move more kernel decompression bits to .init.* sections Date: Wed, 09 Mar 2011 11:13:44 +0000 Message-ID: <4D776EF802000078000357AC@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartCAE6FDF8.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartCAE6FDF8.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -152,6 +152,18 @@ _clean_%/: FORCE %.o: %.S Makefile $(CC) $(AFLAGS) -c $< -o $@ =20 +SPECIAL_DATA_SECTIONS :=3D 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 =3D 0 || \ + { echo "Error: size of $<:$$name is 0x$$sz" >&2; = exit $$idx; };; \ + esac; \ + done + $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section = .$(s)=3D.init.$(s)) $< $@ + %.i: %.c Makefile $(CPP) $(CFLAGS) $< -o $@ =20 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -10,6 +10,7 @@ subdir-$(x86_64) +=3D x86_64 =20 obj-y +=3D apic.o obj-y +=3D bitops.o +obj-bin-y +=3D bzimage.init.o obj-bin-y +=3D clear_page.o obj-bin-y +=3D copy_page.o obj-y +=3D compat.o @@ -55,7 +56,6 @@ obj-y +=3D machine_kexec.o obj-y +=3D crash.o obj-y +=3D tboot.o obj-y +=3D hpet.o -obj-y +=3D bzimage.o =20 obj-$(crash_debug) +=3D gdbstub.o =20 --- a/xen/arch/x86/bzimage.c +++ b/xen/arch/x86/bzimage.c @@ -9,21 +9,21 @@ =20 #define HEAPORDER 3 =20 -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; =20 #define WSIZE 0x80000000 =20 -static unsigned char *inbuf; -static unsigned insize; +static unsigned char *__initdata inbuf; +static unsigned __initdata insize; =20 /* Index of next byte to be processed in inbuf: */ -static unsigned inptr; +static unsigned __initdata inptr; =20 /* Bytes in output buffer: */ -static unsigned outcnt; +static unsigned __initdata outcnt; =20 #define OF(args) args #define STATIC static @@ -34,7 +34,8 @@ typedef unsigned char uch; typedef unsigned short ush; typedef unsigned long ulg; =20 -#define INIT __init +#define INIT __init +#define INITDATA __initdata =20 #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) =20 @@ -55,7 +56,7 @@ typedef unsigned long ulg; # define Tracecv(c, x) #endif =20 -static long bytes_out; +static long __initdata bytes_out; static void flush_window(void); =20 static __init void error(char *x) --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -43,7 +43,7 @@ obj-y +=3D radix-tree.o obj-y +=3D rbtree.o obj-y +=3D lzo.o =20 -obj-$(CONFIG_X86) +=3D decompress.o bunzip2.o unxz.o unlzma.o unlzo.o +obj-bin-$(CONFIG_X86) +=3D $(foreach n,decompress bunzip2 unxz unlzma = unlzo,$(n).init.o) =20 obj-$(perfc) +=3D perfc.o obj-$(crash_debug) +=3D gdbstub.o --- a/xen/common/inflate.c +++ b/xen/common/inflate.c @@ -120,6 +120,7 @@ static char rcsid[] =3D "#Id: inflate.c,v=20 =20 #ifndef INIT #define INIT +#define INITDATA #endif =20 #define slide window @@ -216,8 +217,8 @@ static const ush cpdext[] =3D { /* the stream. */ =20 -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 */ =20 STATIC const ush mask_bits[] =3D { 0x0000, @@ -234,10 +235,10 @@ STATIC const ush mask_bits[] =3D { * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 */ =20 -static unsigned long malloc_ptr; -static int malloc_count; +static unsigned long INITDATA malloc_ptr; +static int INITDATA malloc_count; =20 -static void *malloc(int size) +static void *INIT malloc(int size) { void *p; =20 @@ -258,7 +259,7 @@ static void *malloc(int size) return p; } =20 -static void free(void *where) +static void INIT free(void *where) { malloc_count--; if (!malloc_count) @@ -311,7 +312,7 @@ STATIC const int dbits =3D 6; /*=20 #define N_MAX 288 /* maximum number of codes in any set */ =20 =20 -STATIC unsigned hufts; /* track memory usage */ +STATIC unsigned INITDATA hufts; /* track memory usage */ =20 =20 STATIC int INIT huft_build( @@ -1129,8 +1130,8 @@ STATIC int INIT inflate(void) * **********************************************************************/ =20 -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) =20 /* --- a/xen/common/libelf/Makefile +++ b/xen/common/libelf/Makefile @@ -1,6 +1,6 @@ obj-bin-y :=3D libelf.o =20 -SECTIONS :=3D text data rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) = $(foreach r,rel rel.ro,data.$(r) data.$(r).local) +SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) =20 libelf.o: libelf-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$= (s)) $< $@ --- a/xen/common/unlzma.c +++ b/xen/common/unlzma.c @@ -75,7 +75,7 @@ struct rc { #define RC_MODEL_TOTAL_BITS 11 =20 =20 -static int nofill(void *buffer, unsigned int len) +static int INIT nofill(void *buffer, unsigned int len) { return -1; } --- a/xen/common/xz/dec_bcj.c +++ b/xen/common/xz/dec_bcj.c @@ -87,11 +87,10 @@ static inline int INIT bcj_x86_test_msby =20 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] =3D { true, true, true, false, true, false, false, false = }; =20 - static /*const*/ uint8_t INITDATA mask_to_bit_num[8] - =3D { 0, 1, 2, 2, 3, 3, 3, 3 }; + static const uint8_t mask_to_bit_num[8] =3D { 0, 1, 2, 2, 3, 3, 3, = 3 }; =20 size_t i; size_t prev_pos =3D (size_t)-1; --=__PartCAE6FDF8.0__= Content-Type: text/plain; name="decompress-sections.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="decompress-sections.patch" Based on how c/s 22986:076b63b74cf6 changed xen/libelf/Makefile I=0Asuppose= this is compatibile with those clang/llvm changes, but I=0Adidn't = actually test it.=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/Rules.mk=0A+++ b/xen/Rules.mk=0A@@ -152,6 +152,18 @@ = _clean_%/: FORCE=0A %.o: %.S Makefile=0A $(CC) $(AFLAGS) -c $< -o = $@=0A =0A+SPECIAL_DATA_SECTIONS :=3D rodata $(foreach n,1 2 4 8,rodata.str1= .$(n)) \=0A+ $(foreach r,rel rel.ro,data.$(r) = data.$(r).local)=0A+=0A+%.init.o: %.o Makefile=0A+ $(OBJDUMP) -h $< | = sed -n '/[0-9]/{s,00*,0,g;p}' | while read idx name sz rest; do \=0A+ = case "$$name" in \=0A+ .text|.data|.bss) test $$sz =3D 0 || \=0A+ = { echo "Error: size of $<:$$name is 0x$$sz" >&2; exit = $$idx; };; \=0A+ esac; \=0A+ done=0A+ $(OBJCOPY) = $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=3D.init.$(s)) = $< $@=0A+=0A %.i: %.c Makefile=0A $(CPP) $(CFLAGS) $< -o $@=0A = =0A--- a/xen/arch/x86/Makefile=0A+++ b/xen/arch/x86/Makefile=0A@@ -10,6 = +10,7 @@ subdir-$(x86_64) +=3D x86_64=0A =0A obj-y +=3D apic.o=0A obj-y = +=3D bitops.o=0A+obj-bin-y +=3D bzimage.init.o=0A obj-bin-y +=3D clear_page= .o=0A obj-bin-y +=3D copy_page.o=0A obj-y +=3D compat.o=0A@@ -55,7 +56,6 = @@ obj-y +=3D machine_kexec.o=0A obj-y +=3D crash.o=0A obj-y +=3D = tboot.o=0A obj-y +=3D hpet.o=0A-obj-y +=3D bzimage.o=0A =0A obj-$(crash_deb= ug) +=3D gdbstub.o=0A =0A--- a/xen/arch/x86/bzimage.c=0A+++ b/xen/arch/x86/= bzimage.c=0A@@ -9,21 +9,21 @@=0A =0A #define HEAPORDER 3=0A =0A-static = unsigned char *window;=0A+static unsigned char *__initdata window;=0A = #define memptr long=0A-static memptr free_mem_ptr;=0A-static memptr = free_mem_end_ptr;=0A+static memptr __initdata free_mem_ptr;=0A+static = memptr __initdata free_mem_end_ptr;=0A =0A #define WSIZE = 0x80000000=0A =0A-static unsigned char *inbuf;=0A-static unsigned = insize;=0A+static unsigned char *__initdata inbuf;=0A+static unsigned = __initdata insize;=0A =0A /* Index of next byte to be processed in inbuf: = */=0A-static unsigned inptr;=0A+static unsigned __initdata = inptr;=0A =0A /* Bytes in output buffer: */=0A-static unsigned = outcnt;=0A+static unsigned __initdata outcnt;=0A =0A #define OF(args) = args=0A #define STATIC static=0A@@ -34,7 +34,8 @@ typedef = unsigned char uch;=0A typedef unsigned short ush;=0A typedef unsigned = long ulg;=0A =0A-#define INIT __init=0A+#define INIT = __init=0A+#define INITDATA __initdata=0A =0A #define get_byte() = (inptr < insize ? inbuf[inptr++] : fill_inbuf())=0A =0A@@ -55,7 +56,7 @@ = typedef unsigned long ulg;=0A # define Tracecv(c, x)=0A #endif=0A = =0A-static long bytes_out;=0A+static long __initdata bytes_out;=0A static = void flush_window(void);=0A =0A static __init void error(char *x)=0A--- = a/xen/common/Makefile=0A+++ b/xen/common/Makefile=0A@@ -43,7 +43,7 @@ = obj-y +=3D radix-tree.o=0A obj-y +=3D rbtree.o=0A obj-y +=3D lzo.o=0A = =0A-obj-$(CONFIG_X86) +=3D decompress.o bunzip2.o unxz.o unlzma.o = unlzo.o=0A+obj-bin-$(CONFIG_X86) +=3D $(foreach n,decompress bunzip2 unxz = unlzma unlzo,$(n).init.o)=0A =0A obj-$(perfc) +=3D perfc.o=0A = obj-$(crash_debug) +=3D gdbstub.o=0A--- a/xen/common/inflate.c=0A+++ = b/xen/common/inflate.c=0A@@ -120,6 +120,7 @@ static char rcsid[] =3D "#Id: = inflate.c,v =0A =0A #ifndef INIT=0A #define INIT=0A+#define INITDATA=0A = #endif=0A =0A #define slide window=0A@@ -216,8 +217,8 @@ static const ush = cpdext[] =3D { /*=0A the stream.=0A */=0A =0A-STATIC ulg bb; = /* bit buffer */=0A-STATIC unsigned bk; = /* bits in bit buffer */=0A+STATIC ulg INITDATA bb; = /* bit buffer */=0A+STATIC unsigned INITDATA bk; /* bits in bit = buffer */=0A =0A STATIC const ush mask_bits[] =3D {=0A 0x0000,=0A@@ = -234,10 +235,10 @@ STATIC const ush mask_bits[] =3D {=0A * malloc by = Hannu Savolainen 1993 and Matthias Urlichs 1994=0A */=0A =0A-static = unsigned long malloc_ptr;=0A-static int malloc_count;=0A+static unsigned = long INITDATA malloc_ptr;=0A+static int INITDATA malloc_count;=0A = =0A-static void *malloc(int size)=0A+static void *INIT malloc(int size)=0A = {=0A void *p;=0A =0A@@ -258,7 +259,7 @@ static void *malloc(int = size)=0A return p;=0A }=0A =0A-static void free(void *where)=0A+static = void INIT free(void *where)=0A {=0A malloc_count--;=0A if = (!malloc_count)=0A@@ -311,7 +312,7 @@ STATIC const int dbits =3D 6; = /* =0A #define N_MAX 288 /* maximum number of codes in any set = */=0A =0A =0A-STATIC unsigned hufts; /* track memory usage = */=0A+STATIC unsigned INITDATA hufts; /* track memory usage */=0A =0A = =0A STATIC int INIT huft_build(=0A@@ -1129,8 +1130,8 @@ STATIC int INIT = inflate(void)=0A *=0A ***************************************************= *******************/=0A =0A-static ulg crc_32_tab[256];=0A-static ulg crc; = /* initialized in makecrc() so it'll reside in bss */=0A+static ulg = INITDATA crc_32_tab[256];=0A+static ulg INITDATA crc; /* initialized in = makecrc() so it'll reside in bss */=0A #define CRC_VALUE (crc ^ 0xffffffffU= L)=0A =0A /*=0A--- a/xen/common/libelf/Makefile=0A+++ b/xen/common/libelf/M= akefile=0A@@ -1,6 +1,6 @@=0A obj-bin-y :=3D libelf.o=0A =0A-SECTIONS :=3D = text data rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) $(foreach r,rel = rel.ro,data.$(r) data.$(r).local)=0A+SECTIONS :=3D text data $(SPECIAL_DATA= _SECTIONS)=0A =0A libelf.o: libelf-temp.o Makefile=0A $(OBJCOPY) = $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$(s)) $< $@=0A--- = a/xen/common/unlzma.c=0A+++ b/xen/common/unlzma.c=0A@@ -75,7 +75,7 @@ = struct rc {=0A #define RC_MODEL_TOTAL_BITS 11=0A =0A =0A-static int = nofill(void *buffer, unsigned int len)=0A+static int INIT nofill(void = *buffer, unsigned int len)=0A {=0A return -1;=0A }=0A--- a/xen/common/= xz/dec_bcj.c=0A+++ b/xen/common/xz/dec_bcj.c=0A@@ -87,11 +87,10 @@ static = inline int INIT bcj_x86_test_msby=0A =0A static size_t INIT bcj_x86(struct = xz_dec_bcj *s, uint8_t *buf, size_t size)=0A {=0A- static /*const*/ = bool_t INITDATA mask_to_allowed_status[8]=0A+ static const bool_t = mask_to_allowed_status[8]=0A =3D { true, true, true, false, = true, false, false, false };=0A =0A- static /*const*/ uint8_t INITDATA = mask_to_bit_num[8]=0A- =3D { 0, 1, 2, 2, 3, 3, 3, 3 };=0A+ = static const uint8_t mask_to_bit_num[8] =3D { 0, 1, 2, 2, 3, 3, 3, 3 };=0A = =0A size_t i;=0A size_t prev_pos =3D (size_t)-1;=0A --=__PartCAE6FDF8.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartCAE6FDF8.0__=--