Michal Ostrowski
2005-Aug-30 12:22 UTC
[Xen-devel] [PATCH][1/4] Cross-compilation enablement.
Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com> changeset: 6334:28c822457019 user: mostrows@heater.watson.ibm.com date: Mon Aug 29 18:48:06 2005 -0400 summary: Fixes for cross-compilation; ensure that toolchain is selected by Config.mk diff -r 648c366d588b -r 28c822457019 tools/console/Makefile --- a/tools/console/Makefile Tue Aug 23 13:53:04 2005 +++ b/tools/console/Makefile Mon Aug 29 22:48:06 2005 @@ -9,8 +9,7 @@ INSTALL_PROG = $(INSTALL) -m0755 INSTALL_DIR = $(INSTALL) -d -m0755 -CC = gcc -CFLAGS = -Wall -Werror -g3 +CFLAGS += -Wall -Werror -g3 CFLAGS += -I $(XEN_XCS) CFLAGS += -I $(XEN_LIBXC) diff -r 648c366d588b -r 28c822457019 tools/examples/Makefile --- a/tools/examples/Makefile Tue Aug 23 13:53:04 2005 +++ b/tools/examples/Makefile Mon Aug 29 22:48:06 2005 @@ -1,3 +1,6 @@ +XEN_ROOT = ../../ +include $(XEN_ROOT)/tools/Rules.mk + INSTALL = install INSTALL_DIR = $(INSTALL) -d -m0755 INSTALL_PROG = $(INSTALL) -m0755 diff -r 648c366d588b -r 28c822457019 tools/xcutils/Makefile --- a/tools/xcutils/Makefile Tue Aug 23 13:53:04 2005 +++ b/tools/xcutils/Makefile Mon Aug 29 22:48:06 2005 @@ -18,8 +18,6 @@ PROGRAMS_INSTALL_DIR = /usr/libexec/xen INCLUDES += -I $(XEN_LIBXC) - -CC := gcc CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing CFLAGS += $(INCLUDES) diff -r 648c366d588b -r 28c822457019 tools/xenstat/Makefile --- a/tools/xenstat/Makefile Tue Aug 23 13:53:04 2005 +++ b/tools/xenstat/Makefile Mon Aug 29 22:48:06 2005 @@ -3,7 +3,11 @@ SUBDIRS : SUBDIRS += libxenstat + +# This doesn''t cross-compile (cross-compile environments rarely have curses) +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) SUBDIRS += xentop +endif .PHONY: all install clean _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Michal Ostrowski
2005-Aug-30 12:24 UTC
[Xen-devel] [PATCH][2/4] Cross-compilation enablement.
Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com> changeset: 6335:b8dfe20a5b9d user: mostrows@heater.watson.ibm.com date: Mon Aug 29 18:52:56 2005 -0400 summary: Make mbootpack work on big-endian systems. diff -r 28c822457019 -r b8dfe20a5b9d tools/misc/mbootpack/Makefile --- a/tools/misc/mbootpack/Makefile Mon Aug 29 22:48:06 2005 +++ b/tools/misc/mbootpack/Makefile Mon Aug 29 22:52:56 2005 @@ -20,11 +20,10 @@ INCS := -I. -I- DEFS := LDFLAGS := -CC := gcc CFLAGS := -Wall -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format CFLAGS += -Wmissing-prototypes -#CFLAGS += -pipe -g -O0 -Wcast-align -CFLAGS += -pipe -O3 +CFLAGS += -pipe -g -O0 -Wcast-align +#CFLAGS += -pipe -O3 # What object files need building for the program OBJS := mbootpack.o buildimage.o @@ -34,7 +33,7 @@ DEPS = .*.d mbootpack: $(OBJS) - $(CC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) + $(HOSTCC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) clean: $(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c @@ -48,20 +47,22 @@ $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@ bin2c: bin2c.o - $(CC) -o $@ $^ + $(HOSTCC) -o $@ $^ bzimage_header.c: bootsect setup bin2c ./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c ./bin2c -n 8 -b1 -a bzimage_setup setup >> bzimage_header.c + buildimage.c: bzimage_header.c @ %.o: %.S - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ %.o: %.c - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + .PHONY: all clean gdb .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS) diff -r 28c822457019 -r b8dfe20a5b9d tools/misc/mbootpack/buildimage.c --- a/tools/misc/mbootpack/buildimage.c Mon Aug 29 22:48:06 2005 +++ b/tools/misc/mbootpack/buildimage.c Mon Aug 29 22:52:56 2005 @@ -42,6 +42,7 @@ #include "mbootpack.h" #include "mb_header.h" + /* We will build an image that a bzImage-capable bootloader will load like * this: @@ -105,8 +106,8 @@ section_t *s; /* Patch the kernel and mbi addresses into the setup code */ - *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = entry; - *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = mbi; + *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry); + *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi); if (!quiet) printf("Kernel entry is %p, MBI is %p.\n", entry, mbi); /* Write out header and trampoline */ diff -r 28c822457019 -r b8dfe20a5b9d tools/misc/mbootpack/mbootpack.c --- a/tools/misc/mbootpack/mbootpack.c Mon Aug 29 22:48:06 2005 +++ b/tools/misc/mbootpack/mbootpack.c Mon Aug 29 22:52:56 2005 @@ -252,20 +252,21 @@ for (i = 0; i <= MIN(len - 12, MULTIBOOT_SEARCH - 12); i += 4) { mbh = (struct multiboot_header *)(headerbuf + i); - if (mbh->magic != MULTIBOOT_MAGIC - || ((mbh->magic+mbh->flags+mbh->checksum) & 0xffffffff)) + if (eswap(mbh->magic) != MULTIBOOT_MAGIC + || ((eswap(mbh->magic)+eswap(mbh->flags)+eswap(mbh->checksum)) + & 0xffffffff)) { /* Not a multiboot header */ continue; } - if (mbh->flags & MULTIBOOT_UNSUPPORTED) { + if (eswap(mbh->flags) & MULTIBOOT_UNSUPPORTED) { /* Requires options we don''t support */ printf("Fatal: found a multiboot header, but it " "requires multiboot options that I\n" "don''t understand. Sorry.\n"); exit(1); } - if (mbh->flags & MULTIBOOT_VIDEO_MODE) { + if (eswap(mbh->flags) & MULTIBOOT_VIDEO_MODE) { /* Asked for screen mode information */ /* XXX carry on regardless */ printf("Warning: found a multiboot header which asks " @@ -275,22 +276,22 @@ } /* This kernel will do: place and load it */ - if (mbh->flags & MULTIBOOT_AOUT_KLUDGE) { + if (eswap(mbh->flags) & MULTIBOOT_AOUT_KLUDGE) { /* Load using the offsets in the multiboot header */ if(!quiet) printf("Loading %s using multiboot header.\n", filename); /* How much is there? */ - start = mbh->load_addr; - if (mbh->load_end_addr != 0) - loadsize = mbh->load_end_addr - mbh->load_addr; + start = eswap(mbh->load_addr); + if (eswap(mbh->load_end_addr) != 0) + loadsize = eswap(mbh->load_end_addr) - eswap(mbh->load_addr); else loadsize = sb.st_size; /* How much memory will it take up? */ - if (mbh->bss_end_addr != 0) - size = mbh->bss_end_addr - mbh->load_addr; + if (eswap(mbh->bss_end_addr) != 0) + size = eswap(mbh->bss_end_addr) - eswap(mbh->load_addr); else size = loadsize; @@ -335,32 +336,34 @@ /* Done. */ if (!quiet) printf("Loaded kernel from %s\n", filename); - return mbh->entry_addr; + return eswap(mbh->entry_addr); } else { /* Now look for an ELF32 header */ ehdr = (Elf32_Ehdr *)headerbuf; - if (*(unsigned long *)ehdr != 0x464c457f + if (*(unsigned long *)ehdr != eswap(0x464c457f) || ehdr->e_ident[EI_DATA] != ELFDATA2LSB || ehdr->e_ident[EI_CLASS] != ELFCLASS32 - || ehdr->e_machine != EM_386) + || eswap(ehdr->e_machine) != EM_386) { printf("Fatal: kernel has neither ELF32/x86 nor multiboot load" " headers.\n"); exit(1); } - if (ehdr->e_phoff + ehdr->e_phnum*sizeof(*phdr) > HEADERBUF_SIZE) { + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof(*phdr) + > HEADERBUF_SIZE) { /* Don''t expect this will happen with sane kernels */ printf("Fatal: too much ELF for me. Try increasing " "HEADERBUF_SIZE in mbootpack.\n"); exit(1); } - if (ehdr->e_phoff + ehdr->e_phnum*sizeof (*phdr) > len) { + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof (*phdr) + > len) { printf("Fatal: malformed ELF header overruns EOF.\n"); exit(1); } - if (ehdr->e_phnum <= 0) { + if (eswap(ehdr->e_phnum) <= 0) { printf("Fatal: ELF kernel has no program headers.\n"); exit(1); } @@ -368,22 +371,22 @@ if(!quiet) printf("Loading %s using ELF header.\n", filename); - if (ehdr->e_type != ET_EXEC - || ehdr->e_version != EV_CURRENT - || ehdr->e_phentsize != sizeof (Elf32_Phdr)) { + if (eswap(ehdr->e_type) != ET_EXEC + || eswap(ehdr->e_version) != EV_CURRENT + || eswap(ehdr->e_phentsize) != sizeof (Elf32_Phdr)) { printf("Warning: funny-looking ELF header.\n"); } - phdr = (Elf32_Phdr *)(headerbuf + ehdr->e_phoff); + phdr = (Elf32_Phdr *)(headerbuf + eswap(ehdr->e_phoff)); /* Obey the program headers to load the kernel */ - for(i = 0; i < ehdr->e_phnum; i++) { - - start = phdr[i].p_paddr; - size = phdr[i].p_memsz; - if (phdr[i].p_type != PT_LOAD) + for(i = 0; i < eswap(ehdr->e_phnum); i++) { + + start = eswap(phdr[i].p_paddr); + size = eswap(phdr[i].p_memsz); + if (eswap(phdr[i].p_type) != PT_LOAD) loadsize = 0; else - loadsize = MIN((long int)phdr[i].p_filesz, size); + loadsize = MIN((long int)eswap(phdr[i].p_filesz), size); if ((buffer = malloc(size)) == NULL) { printf("Fatal: malloc() for kernel load failed: %s\n", @@ -396,7 +399,7 @@ /* Load section from file */ if (loadsize > 0) { - if (fseek(fp, phdr[i].p_offset, SEEK_SET) != 0) { + if (fseek(fp, eswap(phdr[i].p_offset), SEEK_SET) != 0) { printf("Fatal: seek failed in %s\n", strerror(errno)); exit(1); @@ -452,7 +455,7 @@ /* Done! */ if (!quiet) printf("Loaded kernel from %s\n", filename); - return ehdr->e_entry; + return eswap(ehdr->e_entry); } } @@ -568,12 +571,12 @@ /* Command line */ p = (char *)(mbi + 1); sprintf(p, "%s %s", imagename, command_line); - mbi->cmdline = ((address_t)p) + mbi_reloc_offset; + mbi->cmdline = eswap(((address_t)p) + mbi_reloc_offset); p += command_line_len; /* Bootloader ID */ sprintf(p, version_string); - mbi->boot_loader_name = ((address_t)p) + mbi_reloc_offset; + mbi->boot_loader_name = eswap(((address_t)p) + mbi_reloc_offset); p += strlen(version_string) + 1; /* Next is space for the module command lines */ @@ -582,17 +585,17 @@ /* Last come the module info structs */ modp = (struct mod_list *) ((((address_t)p + mod_command_line_space) + 3) & ~3); - mbi->mods_count = modules; - mbi->mods_addr = ((address_t)modp) + mbi_reloc_offset; + mbi->mods_count = eswap(modules); + mbi->mods_addr = eswap(((address_t)modp) + mbi_reloc_offset); /* Memory information will be added at boot time, by setup.S * or trampoline.S. */ - mbi->flags = MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME; + mbi->flags = eswap(MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME); /* Load the modules */ if (modules) { - mbi->flags |= MB_INFO_MODS; + mbi->flags = eswap(eswap(mbi->flags) | MB_INFO_MODS); /* Go back and parse the module command lines */ optind = opterr = 1; @@ -652,10 +655,10 @@ if (p != NULL) *p = '' ''; /* Fill in the module info struct */ - modp->mod_start = start; - modp->mod_end = start + size; - modp->cmdline = (address_t)mod_clp + mbi_reloc_offset; - modp->pad = 0; + modp->mod_start = eswap(start); + modp->mod_end = eswap(start + size); + modp->cmdline = eswap((address_t)mod_clp + mbi_reloc_offset); + modp->pad = eswap(0); modp++; /* Store the module command line */ diff -r 28c822457019 -r b8dfe20a5b9d tools/misc/mbootpack/mbootpack.h --- a/tools/misc/mbootpack/mbootpack.h Mon Aug 29 22:48:06 2005 +++ b/tools/misc/mbootpack/mbootpack.h Mon Aug 29 22:52:56 2005 @@ -31,6 +31,24 @@ #undef NDEBUG #include <stdio.h> + +#include <endian.h> +#include <byteswap.h> +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define eswap(x) (x) +#else +#define eswap(x) \ + ({ \ + typeof(x) y = (x); \ + switch(sizeof(y)) \ + { \ + case 2: y = __bswap_16(y); break; \ + case 4: y = __bswap_32(y); break; \ + case 8: y = __bswap_64(y); break; \ + } \ + y; \ + }) +#endif /* Flags */ extern int quiet; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Michal Ostrowski
2005-Aug-30 12:25 UTC
[Xen-devel] [PATCH][3/4] Cross-compilation enablement.
Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com> changeset: 6468:f22c08b57c9a user: mostrows@heater.watson.ibm.com date: Mon Aug 29 19:45:28 2005 -0400 summary: Fixes for cross-compilation. diff -r 883365aa1b7d -r f22c08b57c9a tools/Makefile --- a/tools/Makefile Mon Aug 29 23:41:47 2005 +++ b/tools/Makefile Mon Aug 29 23:45:28 2005 @@ -7,14 +7,18 @@ SUBDIRS += misc SUBDIRS += examples SUBDIRS += xentrace -SUBDIRS += python SUBDIRS += xcs SUBDIRS += xcutils -#SUBDIRS += pygrub SUBDIRS += firmware SUBDIRS += security SUBDIRS += console SUBDIRS += xenstat + +# These don''t cross-compile +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) +SUBDIRS += python +#SUBDIRS += pygrub +endif .PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Michal Ostrowski
2005-Aug-30 12:26 UTC
[Xen-devel] [PATCH][4/4] Cross-compilation enablement.
Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com> changeset: 6474:b6a82de711aa user: mostrows@heater.watson.ibm.com date: Tue Aug 30 08:01:02 2005 -0400 summary: Cross-compilation fixes. CC comes from Config.mk diff -r ae90fb6022ba -r b6a82de711aa tools/xcs/Makefile --- a/tools/xcs/Makefile Tue Aug 30 12:00:42 2005 +++ b/tools/xcs/Makefile Tue Aug 30 12:01:02 2005 @@ -10,8 +10,7 @@ INSTALL_PROG = $(INSTALL) -m0755 INSTALL_DIR = $(INSTALL) -d -m0755 -CC = gcc -CFLAGS = -Wall -Werror -g3 -D _XOPEN_SOURCE=600 +CFLAGS += -Wall -Werror -g3 -D _XOPEN_SOURCE=600 CFLAGS += -I $(XEN_XC) CFLAGS += -I $(XEN_LIBXC) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2005-Aug-30 13:08 UTC
Re: [Xen-devel] [PATCH][1/4] Cross-compilation enablement.
Every one of the five patches that you just mailed were chewed by your mail client. Please resend them as attachments (just send a single multi-attachment email). Also, if you cannot cross-compile all the tool chain (including important Python-based components), what is the point in cross-compiling any of them? I guess most of your patches are cleanups, and mbootpack is executed on the compile host, but still I wonder. :-) -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2005-Aug-30 13:12 UTC
Re: [Xen-devel] [PATCH][1/4] Cross-compilation enablement.
On 30 Aug 2005, at 14:08, Keir Fraser wrote:> Every one of the five patches that you just mailed were chewed by your > mail client. Please resend them as attachments (just send a single > multi-attachment email).Actually they''re fine, just mime encoded. My bad. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Michal Ostrowski
2005-Aug-30 13:26 UTC
Re: [Xen-devel] [PATCH][1/4] Cross-compilation enablement.
On Tue, 30 Aug 2005 14:08:40 +0100 Keir Fraser <Keir.Fraser@cl.cam.ac.uk> wrote:> > Also, if you cannot cross-compile all the tool chain (including > important Python-based components), what is the point in > cross-compiling any of them? I guess most of your patches are cleanups, > and mbootpack is executed on the compile host, but still I wonder. :-) > >a) The python cross-compilation problems stem from the fact that python facilities are being used to build your python-binding libraries. I don''t see an easy way to tell those tools that they should be cross-compiling. Setting CC and CFLAGS and the like is not enough; the python tools need to realize that they must build using a python installation that is not the installation that is being used to run the build. Cross-compilation environments also tend to be fairly poor in terms of the libraries that are present and my experience has been that higher-level libraries and tools tend to be less cross-compilation friendly. b) I''m not assuming I can fix everything in one shot. c) I can cross-compile vm-tools. -- Michal Ostrowski _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel