[MBOOTPACK] Fix building mbootpack on x86/64.

Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
kaf24@firebug.cl.cam.ac.uk committed 2006-10-05 12:08:08 +01:00
1 parent 9bc9168a08
commit ff858e5b2f
3 files changed
+24 -32

No files matched your search

+5 -12
View File
@@ -20,12 +20,8 @@ install: build
# Tools etc.
RM := rm -f
GDB := gdb
INCS := -I. -I-
DEFS :=
LDFLAGS :=
CFLAGS += -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format
CFLAGS += -Wmissing-prototypes -pipe
# What object files need building for the program
OBJS := mbootpack.o buildimage.o
@@ -35,22 +31,22 @@ DEPFLAGS = -Wp,-MD,.$(@F).d
DEPS = .*.d
mbootpack: $(OBJS)
$(HOSTCC) -o $@ $(filter-out %.a, $^)
$(HOSTCC) $(HOSTCFLAGS) -o $@ $(filter-out %.a, $^)
.PHONY: clean
clean:
$(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c
bootsect: bootsect.S
$(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o
$(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o
$(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary bootsect.o -o $@
setup: setup.S
$(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o
$(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o
$(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@
bin2c: bin2c.o
$(HOSTCC) -o $@ $^
$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
bzimage_header.c: bootsect setup bin2c
./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c
@@ -59,11 +55,8 @@ bzimage_header.c: bootsect setup bin2c
buildimage.c: bzimage_header.c
@
%.o: %.S
$(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@
%.o: %.c
$(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@
$(HOSTCC) $(DEPFLAGS) $(HOSTCFLAGS) $(INCS) $(DEFS) -c $< -o $@
.PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS)
.SUFFIXES:
+10 -9
View File
@@ -25,8 +25,6 @@
*
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -77,20 +75,22 @@
/* Bring in the bzImage boot sector and setup code */
#include "bzimage_header.c"
#define _p(x) ((void *)(unsigned long)(x))
address_t place_mbi(long int size)
/* Find space at the top of *low* memory for the MBI and associated red tape */
{
address_t start;
start = 0xa000 - size;
if (start < 0x9000 + sizeof(bzimage_bootsect) + sizeof(bzimage_setup)) {
printf("Fatal: command-lines too long: need %i, have %i bytes\n",
printf("Fatal: command-lines too long: need %ld, have %ld bytes\n",
size,
0x1000 - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup)));
exit(1);
0x1000L - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup)));
exit(1);
}
if (!quiet) {
printf("Placed MBI and strings (%p+%p)\n",
start, size);
_p(start), _p(size));
}
return start;
}
@@ -108,7 +108,7 @@ void make_bzImage(section_t *sections,
/* Patch the kernel and mbi addresses into the setup code */
*(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);
if (!quiet) printf("Kernel entry is %p, MBI is %p.\n",_p(entry), _p(mbi));
/* Write out header and trampoline */
if (fseek(fp, 0, SEEK_SET) < 0) {
@@ -127,8 +127,9 @@ void make_bzImage(section_t *sections,
exit(1);
}
if (!quiet) printf("Wrote bzImage header: %i + %i bytes.\n",
sizeof(bzimage_bootsect), sizeof(bzimage_setup));
if (!quiet) printf("Wrote bzImage header: %ld + %ld bytes.\n",
(long)sizeof(bzimage_bootsect),
(long)sizeof(bzimage_setup));
/* Sorted list of sections below 1MB: write them out */
for (s = sections, i = 0; s; s = s->next) {
+9 -11
View File
@@ -128,6 +128,7 @@ static void usage(void)
exit(1);
}
#define _p(x) ((void *)(unsigned long)(x))
static void place_kernel_section(address_t start, long int size)
/* Place the kernel in memory, checking for the memory hole. */
@@ -136,7 +137,8 @@ static void place_kernel_section(address_t start, long int size)
/* Above the memory hole: easy */
next_free_space = MAX(next_free_space, start + size);
if (!quiet) {
printf("Placed kernel section (%p+%p)\n", start, size);
printf("Placed kernel section (%p+%p)\n",
_p(start), _p(size));
}
return;
}
@@ -144,14 +146,14 @@ static void place_kernel_section(address_t start, long int size)
if (start >= MEM_HOLE_START) {
/* In the memory hole. Not so good */
printf("Fatal: kernel load address (%p) is in the memory hole.\n",
start);
_p(start));
exit(1);
}
if (start + size > MEM_HOLE_START) {
/* Too big for low memory */
printf("Fatal: kernel (%p+%p) runs into the memory hole.\n",
start, size);
_p(start), _p(size));
exit(1);
}
@@ -159,7 +161,7 @@ static void place_kernel_section(address_t start, long int size)
next_free_space = MAX(next_free_space, start + size);
if (!quiet) {
printf("Placed kernel section (%p+%p)\n", start, size);
printf("Placed kernel section (%p+%p)\n", _p(start), _p(size));
}
}
@@ -182,14 +184,12 @@ static address_t place_section(long int size, int align)
if (!quiet) {
printf("Placed section (%p+%p), align=%p\n",
start, size, align);
_p(start), _p(size), _p(align));
}
return start;
}
static address_t load_kernel(const char *filename)
/* Load an elf32/multiboot kernel from this file
* Returns the entry address for the kernel. */
@@ -296,7 +296,7 @@ static address_t load_kernel(const char *filename)
size = loadsize;
if (loadsize > size) {
printf("Fatal: can't load %i bytes of kernel into %i bytes "
printf("Fatal: can't load %ld bytes of kernel into %ld bytes "
"of memory.\n", loadsize, size);
exit(1);
}
@@ -466,8 +466,6 @@ static address_t load_kernel(const char *filename)
}
int main(int argc, char **argv)
{
char *buffer, *imagename, *command_line, *p;
@@ -480,7 +478,7 @@ int main(int argc, char **argv)
struct mod_list *modp;
address_t start, kernel_entry;
long int size, mod_command_line_space, command_line_len;
int modules, opt, mbi_reloc_offset, make_multiboot;
int modules, opt, mbi_reloc_offset;
static const char short_options[] = "hc:m:o:qM";
static const struct option options[] = {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.