x86 Boot enhancements, build enhancements 6/9
PATCH 1/1 x86 Boot enhancements, build enhancements 6/9
Linus, please apply
When building a zImage or a bzImage there is currently an enormous amount of data loss. In particular we lose all information about how much memory the loaded kernel actually uses during bootstrap. This makes understanding the boot process quite difficult, and it makes implementing a ramdisk that loads immediately after the kernel in memory impossible.
Rework the actual build/link step for kernel images.
- remove the need for objcopy
- Kill the ROOT_DEV Makefile variable, the implementation was only half correct and there are much better ways to specify your root device than modifying the kernel.
- Don't loose information when the executable is built
Except for a few extra fields in setup.S the binary image is unchanged.
Eric
Makefile +0 -9
@@ -93,15 +93,6 @@ AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) # -# ROOT_DEV specifies the default root-device when making the image. -# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case -# the default of FLOPPY is used by 'build'. -# This is i386 specific. -# - -export ROOT_DEV = CURRENT - -# # If you want to preset the SVGA mode, uncomment the next line and # set SVGA_MODE to whatever number you want. # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
arch/i386/boot/Makefile +14 -22
@@ -12,13 +12,11 @@ $(TOPDIR)/include/linux/autoconf.h \ $(TOPDIR)/include/asm/boot.h -zImage: $(CONFIGURE) bootsect setup compressed/vmlinux tools/build - $(OBJCOPY) compressed/vmlinux compressed/vmlinux.out - tools/build bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage - -bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build - $(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out - tools/build -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage +zImage: $(CONFIGURE) tools/build $(TOPDIR)/vmlinux realmode compressed/vmlinux + tools/build $(TOPDIR)/vmlinux realmode compressed/vmlinux zImage + +bzImage: $(CONFIGURE) tools/build $(TOPDIR)/vmlinux brealmode compressed/bvmlinux + tools/build -b $(TOPDIR)/vmlinux brealmode compressed/bvmlinux bzImage compressed/vmlinux: $(TOPDIR)/vmlinux @$(MAKE) -C compressed vmlinux
@@ -39,49 +37,43 @@ install: $(CONFIGURE) $(BOOTIMAGE) sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map "$(INSTALL_PATH)" -tools/build: tools/build.c +tools/build: tools/build.c $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h $(TOPDIR)/include/asm-i386/boot.h $(HOSTCC) $(HOSTCFLAGS) -o $@ $< -I$(TOPDIR)/include -bootsect: bootsect.o - $(LD) -Ttext 0x0 -s --oformat binary -o $@ $< - bootsect.o: bootsect.s $(AS) -o $@ $< bootsect.s: bootsect.S Makefile $(BOOT_INCL) $(CPP) $(CPPFLAGS) -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@ -bbootsect: bbootsect.o - $(LD) -Ttext 0x0 -s --oformat binary $< -o $@ - bbootsect.o: bbootsect.s $(AS) -o $@ $< bbootsect.s: bootsect.S Makefile $(BOOT_INCL) $(CPP) $(CPPFLAGS) -D__BIG_KERNEL__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@ -setup: setup.o - $(LD) -Ttext 0x0 -s --oformat binary -e begtext -o $@ $< - setup.o: setup.s $(AS) -o $@ $< setup.s: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h $(CPP) $(CPPFLAGS) -D__ASSEMBLY__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@ -bsetup: bsetup.o - $(LD) -Ttext 0x0 -s --oformat binary -e begtext -o $@ $< - bsetup.o: bsetup.s $(AS) -o $@ $< bsetup.s: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h $(CPP) $(CPPFLAGS) -D__BIG_KERNEL__ -D__ASSEMBLY__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@ +realmode: bootsect.o setup.o + $(LD) -T realmode.lds -o $@ $^ + +brealmode: bbootsect.o bsetup.o + $(LD) -T realmode.lds -o $@ $^ + dep: clean: rm -f tools/build - rm -f setup bootsect zImage compressed/vmlinux.out - rm -f bsetup bbootsect bzImage compressed/bvmlinux.out + rm -f realmode zImage + rm -f brealmode bzImage @$(MAKE) -C compressed clean
arch/i386/boot/bootsect.S +1 -1
@@ -54,7 +54,7 @@ #endif .code16 -.text +.section ".bootsect", "ax", @progbits .global _start _start:
arch/i386/boot/realmode.lds +20 -0
@@ -0,0 +1,20 @@ +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +ENTRY(_start) +OUTPUT_ARCH(i386) +SECTIONS +{ + . = 0x90000; + .bootsect : { + *(.bootsect) + } + . = 0x90200; + .setup : { + *(.setup) + } + .setup.heap : { + *(.setup.heap) + } + /DISCARD/ : { + *(*) + } +}
arch/i386/boot/setup.S +18 -3
@@ -80,7 +80,7 @@ .code16 .globl _setup, _esetup -.text +.section ".setup", "ax", @progbits _setup: start:
@@ -138,7 +138,7 @@ bootsect_kludge: .word bootsect_helper - start, SETUPSEG -heap_end_ptr: .word _esetup + MIN_HEAP_SIZE - start +heap_end_ptr: .word _esetup_heap - start # (Header version 0x0201 or later) # space from here (exclusive) down to # heap_start can be used by setup
@@ -165,7 +165,18 @@ # the contents of an initrd # variables private to setup.S (not for bootloaders) -real_filesz: .long (_esetup - start) + (DELTA_INITSEG << 4) +pad2: .long 0 +low_base: .long LOW_BASE # low buffer base 0x1000 +low_memsz: .long 0x00000000 # Size of low buffer @ 0x1000 +low_filesz: .long 0x00000000 # Size of precomputed data @ 0x1000 +real_base: .long REAL_BASE # Location of real mode kernel +real_memsz: # Memory usage of real mode kernel @ 0x90000 + .long (_esetup_heap - start) + (DELTA_INITSEG << 4) +real_filesz: # Datasize of real mode kernel @ 0x90000 + .long (_esetup - start) + (DELTA_INITSEG << 4) +high_base: .long HIGH_BASE # high buffer base 0x100000 +high_memsz: .long 0x00000000 # Size of high buffer @ 0x100000 +high_filesz: .long 0x00000000 # Datasize of the linux kernel trampoline: call start_of_setup # Don't let the E820 map overlap code . = (0x2d0 - 0x200) + (E820MAX * E820ENTRY_SIZE)
@@ -1045,3 +1056,7 @@ # handling code to store the temporary mode table (not used by the kernel). _esetup: +.section ".setup.heap", "a", @nobits +_setup_heap: +. = MIN_HEAP_SIZE +_esetup_heap:
arch/i386/boot/tools/build.c +420 -122
603 lines not on this page · raw message
arch/x86_64/boot/Makefile +2 -2
@@ -14,11 +14,11 @@ zImage: $(CONFIGURE) bootsect setup compressed/vmlinux tools/build $(OBJCOPY) compressed/vmlinux compressed/vmlinux.out - tools/build bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage + tools/build bootsect setup compressed/vmlinux.out CURRENT > zImage bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build $(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out - tools/build -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage + tools/build -b bbootsect bsetup compressed/bvmlinux.out CURRENT > bzImage bzImage-padded: bzImage dd if=/dev/zero bs=1k count=70 >> bzImage