ia64/xen-unstable

changeset 11749:2e58022889a5

[MBOOTPACK] Fix building mbootpack on x86/64.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 05 12:08:08 2006 +0100 (2006-10-05)
parents a72fdb6a19a1
children 8959876abbe3
files tools/misc/mbootpack/Makefile tools/misc/mbootpack/buildimage.c tools/misc/mbootpack/mbootpack.c
line diff
     1.1 --- a/tools/misc/mbootpack/Makefile	Thu Oct 05 10:55:13 2006 +0100
     1.2 +++ b/tools/misc/mbootpack/Makefile	Thu Oct 05 12:08:08 2006 +0100
     1.3 @@ -20,12 +20,8 @@ install: build
     1.4  
     1.5  #  Tools etc.
     1.6  RM 	:= rm -f
     1.7 -GDB	:= gdb
     1.8  INCS	:= -I. -I-
     1.9  DEFS	:= 
    1.10 -LDFLAGS	:= 
    1.11 -CFLAGS	+= -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format
    1.12 -CFLAGS	+= -Wmissing-prototypes -pipe
    1.13  
    1.14  #  What object files need building for the program
    1.15  OBJS	:= mbootpack.o buildimage.o
    1.16 @@ -35,22 +31,22 @@ DEPFLAGS = -Wp,-MD,.$(@F).d
    1.17  DEPS     = .*.d
    1.18  
    1.19  mbootpack: $(OBJS)
    1.20 -	$(HOSTCC) -o $@ $(filter-out %.a, $^)
    1.21 +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $(filter-out %.a, $^)
    1.22  
    1.23  .PHONY: clean
    1.24  clean:
    1.25  	$(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c
    1.26  
    1.27  bootsect: bootsect.S
    1.28 -	$(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o
    1.29 +	$(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o
    1.30  	$(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary bootsect.o -o $@
    1.31  
    1.32  setup: setup.S
    1.33 -	$(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o
    1.34 +	$(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o
    1.35  	$(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@
    1.36  
    1.37  bin2c: bin2c.o 
    1.38 -	$(HOSTCC) -o $@ $^ 
    1.39 +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^ 
    1.40  
    1.41  bzimage_header.c: bootsect setup bin2c
    1.42  	./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c
    1.43 @@ -59,11 +55,8 @@ bzimage_header.c: bootsect setup bin2c
    1.44  buildimage.c: bzimage_header.c
    1.45  	@
    1.46  
    1.47 -%.o: %.S
    1.48 -	$(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@
    1.49 -
    1.50  %.o: %.c
    1.51 -	$(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@
    1.52 +	$(HOSTCC) $(DEPFLAGS) $(HOSTCFLAGS) $(INCS) $(DEFS) -c $< -o $@
    1.53  
    1.54  .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS)
    1.55  .SUFFIXES: 
     2.1 --- a/tools/misc/mbootpack/buildimage.c	Thu Oct 05 10:55:13 2006 +0100
     2.2 +++ b/tools/misc/mbootpack/buildimage.c	Thu Oct 05 12:08:08 2006 +0100
     2.3 @@ -25,8 +25,6 @@
     2.4   *
     2.5   */
     2.6  
     2.7 -
     2.8 -
     2.9  #include <assert.h>
    2.10  #include <stdio.h>
    2.11  #include <stdlib.h>
    2.12 @@ -77,20 +75,22 @@
    2.13  /* Bring in the bzImage boot sector and setup code */
    2.14  #include "bzimage_header.c"
    2.15  
    2.16 +#define _p(x) ((void *)(unsigned long)(x))
    2.17 +
    2.18  address_t place_mbi(long int size) 
    2.19  /* Find space at the top of *low* memory for the MBI and associated red tape */
    2.20  {
    2.21      address_t start;
    2.22      start = 0xa000 - size;
    2.23      if (start < 0x9000 + sizeof(bzimage_bootsect) + sizeof(bzimage_setup)) {
    2.24 -        printf("Fatal: command-lines too long: need %i, have %i bytes\n",
    2.25 +        printf("Fatal: command-lines too long: need %ld, have %ld bytes\n",
    2.26                 size, 
    2.27 -               0x1000 - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup)));
    2.28 -        exit(1);        
    2.29 +               0x1000L - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup)));
    2.30 +        exit(1);
    2.31      }
    2.32      if (!quiet) {
    2.33          printf("Placed MBI and strings (%p+%p)\n", 
    2.34 -               start, size);
    2.35 +               _p(start), _p(size));
    2.36      }
    2.37      return start;
    2.38  }
    2.39 @@ -108,7 +108,7 @@ void make_bzImage(section_t *sections,
    2.40      /* Patch the kernel and mbi addresses into the setup code */
    2.41      *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry);
    2.42      *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi);
    2.43 -    if (!quiet) printf("Kernel entry is %p, MBI is %p.\n", entry, mbi);
    2.44 +    if (!quiet) printf("Kernel entry is %p, MBI is %p.\n",_p(entry), _p(mbi));
    2.45  
    2.46      /* Write out header and trampoline */
    2.47      if (fseek(fp, 0, SEEK_SET) < 0) {
    2.48 @@ -127,8 +127,9 @@ void make_bzImage(section_t *sections,
    2.49          exit(1);
    2.50      }
    2.51  
    2.52 -    if (!quiet) printf("Wrote bzImage header: %i + %i bytes.\n", 
    2.53 -                       sizeof(bzimage_bootsect), sizeof(bzimage_setup));
    2.54 +    if (!quiet) printf("Wrote bzImage header: %ld + %ld bytes.\n", 
    2.55 +                       (long)sizeof(bzimage_bootsect),
    2.56 +                       (long)sizeof(bzimage_setup));
    2.57  
    2.58      /* Sorted list of sections below 1MB: write them out */
    2.59      for (s = sections, i = 0; s; s = s->next) {
     3.1 --- a/tools/misc/mbootpack/mbootpack.c	Thu Oct 05 10:55:13 2006 +0100
     3.2 +++ b/tools/misc/mbootpack/mbootpack.c	Thu Oct 05 12:08:08 2006 +0100
     3.3 @@ -128,6 +128,7 @@ static void usage(void)
     3.4      exit(1);
     3.5  }
     3.6  
     3.7 +#define _p(x) ((void *)(unsigned long)(x))
     3.8  
     3.9  static void place_kernel_section(address_t start, long int size)
    3.10  /* Place the kernel in memory, checking for the memory hole. */
    3.11 @@ -136,7 +137,8 @@ static void place_kernel_section(address
    3.12          /* Above the memory hole: easy */
    3.13          next_free_space = MAX(next_free_space, start + size);
    3.14          if (!quiet) {
    3.15 -            printf("Placed kernel section (%p+%p)\n", start, size);
    3.16 +            printf("Placed kernel section (%p+%p)\n",
    3.17 +                   _p(start), _p(size));
    3.18          }
    3.19          return;
    3.20      }
    3.21 @@ -144,14 +146,14 @@ static void place_kernel_section(address
    3.22      if (start >= MEM_HOLE_START) {
    3.23          /* In the memory hole.  Not so good */
    3.24          printf("Fatal: kernel load address (%p) is in the memory hole.\n",
    3.25 -               start);
    3.26 +               _p(start));
    3.27          exit(1);
    3.28      }
    3.29      
    3.30      if (start + size > MEM_HOLE_START) {
    3.31          /* Too big for low memory */
    3.32          printf("Fatal: kernel (%p+%p) runs into the memory hole.\n",
    3.33 -               start, size);
    3.34 +               _p(start), _p(size));
    3.35          exit(1);
    3.36      }	
    3.37      
    3.38 @@ -159,7 +161,7 @@ static void place_kernel_section(address
    3.39      next_free_space = MAX(next_free_space, start + size);
    3.40  
    3.41      if (!quiet) {
    3.42 -        printf("Placed kernel section (%p+%p)\n", start, size);
    3.43 +        printf("Placed kernel section (%p+%p)\n", _p(start), _p(size));
    3.44      }
    3.45  }
    3.46  
    3.47 @@ -182,14 +184,12 @@ static address_t place_section(long int 
    3.48  
    3.49      if (!quiet) {
    3.50          printf("Placed section (%p+%p), align=%p\n", 
    3.51 -               start, size, align);
    3.52 +               _p(start), _p(size), _p(align));
    3.53      }
    3.54      return start;
    3.55  }
    3.56  
    3.57  
    3.58 -
    3.59 -
    3.60  static address_t load_kernel(const char *filename)
    3.61  /* Load an elf32/multiboot kernel from this file 
    3.62   * Returns the entry address for the kernel. */
    3.63 @@ -296,7 +296,7 @@ static address_t load_kernel(const char 
    3.64                  size = loadsize;
    3.65              
    3.66              if (loadsize > size) {
    3.67 -                printf("Fatal: can't load %i bytes of kernel into %i bytes " 
    3.68 +                printf("Fatal: can't load %ld bytes of kernel into %ld bytes "
    3.69                         "of memory.\n", loadsize, size);
    3.70                  exit(1);
    3.71              }
    3.72 @@ -466,8 +466,6 @@ static address_t load_kernel(const char 
    3.73  }
    3.74  
    3.75  
    3.76 -
    3.77 -
    3.78  int main(int argc, char **argv) 
    3.79  {
    3.80      char *buffer, *imagename, *command_line, *p;
    3.81 @@ -480,7 +478,7 @@ int main(int argc, char **argv)
    3.82      struct mod_list *modp;
    3.83      address_t start, kernel_entry;
    3.84      long int size, mod_command_line_space, command_line_len;
    3.85 -    int modules, opt, mbi_reloc_offset, make_multiboot;
    3.86 +    int modules, opt, mbi_reloc_offset;
    3.87  
    3.88      static const char short_options[] = "hc:m:o:qM";
    3.89      static const struct option options[] = {