Compress grub_prefix.

* grub-core/boot/i386/pc/lnxboot.S: Use
	GRUB_KERNEL_I386_PC_MULTIBOOT_SIGNATURE.
	* grub-core/kern/i386/pc/startup.S: Move grub_prefix to compressed part.
	* include/grub/offsets.h: Rename GRUB_MACHINE_DATA_END to
	GRUB_MACHINE_PREFIX_END. All users updated.
	(GRUB_KERNEL_I386_PC_PREFIX): Set to GRUB_KERNEL_I386_PC_RAW_SIZE.
	(GRUB_KERNEL_I386_PC_PREFIX_END): Set to GRUB_KERNEL_I386_PC_PREFIX
	+ 0x40.
	(GRUB_KERNEL_I386_PC_RAW_SIZE): Decrease.
	* util/grub-mkimage.c (image_target_desc): Change data_end to
	prefix_end. All users updated.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-03 14:54:04 +02:00
parent a7c00cdb94
commit c8e7bf5ff7
11 changed files with 67 additions and 46 deletions

View file

@ -1,3 +1,19 @@
2010-09-03 Vladimir Serbinenko <phcoder@gmail.com>
Compress grub_prefix.
* grub-core/boot/i386/pc/lnxboot.S: Use
GRUB_KERNEL_I386_PC_MULTIBOOT_SIGNATURE.
* grub-core/kern/i386/pc/startup.S: Move grub_prefix to compressed part.
* include/grub/offsets.h: Rename GRUB_MACHINE_DATA_END to
GRUB_MACHINE_PREFIX_END. All users updated.
(GRUB_KERNEL_I386_PC_PREFIX): Set to GRUB_KERNEL_I386_PC_RAW_SIZE.
(GRUB_KERNEL_I386_PC_PREFIX_END): Set to GRUB_KERNEL_I386_PC_PREFIX
+ 0x40.
(GRUB_KERNEL_I386_PC_RAW_SIZE): Decrease.
* util/grub-mkimage.c (image_target_desc): Change data_end to
prefix_end. All users updated.
2010-09-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsd.c (grub_freebsd_boot): Set %ebp to sane

View file

@ -185,7 +185,7 @@ real_code_2:
call LOCAL(move_memory)
/* Check for multiboot signature. */
cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END)
cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_I386_PC_MULTIBOOT_SIGNATURE)
jz 1f
movl (ramdisk_image - start), %esi

View file

@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
/*
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).

View file

@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
movl %eax, EXT_C(grub_ieee1275_entry_fn)

View file

@ -100,14 +100,6 @@ VARIABLE(grub_install_dos_part)
.long 0xFFFFFFFF
VARIABLE(grub_install_bsd_part)
.long 0xFFFFFFFF
VARIABLE(grub_prefix)
/* to be filled by grub-mkimage */
/*
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
#ifdef APPLE_CC
bss_start:
@ -450,6 +442,16 @@ gate_a20_check_state:
*/
. = _start + GRUB_KERNEL_MACHINE_RAW_SIZE
. = _start + GRUB_KERNEL_MACHINE_PREFIX
VARIABLE(grub_prefix)
/* to be filled by grub-mkimage */
/*
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
/*
* grub_exit()

View file

@ -39,7 +39,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
/* Relocate to low memory. First we figure out our location.

View file

@ -154,7 +154,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
#ifdef GRUB_MACHINE_MIPS_YEELOONG
VARIABLE (grub_arch_busclock)
.long 0

View file

@ -39,7 +39,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_MACHINE_DATA_END
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
li 2, 0

View file

@ -42,7 +42,7 @@ VARIABLE(grub_prefix)
* Leave some breathing room for the prefix.
*/
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_DATA_END
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_PREFIX_END
codestart:
/* Copy the modules past the end of the kernel image.

View file

@ -34,14 +34,17 @@
/* The offset of GRUB_INSTALL_BSD_PART. */
#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x18
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_PC_PREFIX 0x1c
/* End of the data section. */
#define GRUB_KERNEL_I386_PC_DATA_END 0x5c
/* The offset of multiboot signature. */
#define GRUB_KERNEL_I386_PC_MULTIBOOT_SIGNATURE 0x1c
/* The size of the first region which won't be compressed. */
#define GRUB_KERNEL_I386_PC_RAW_SIZE (GRUB_KERNEL_I386_PC_DATA_END + 0x5F0)
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0x5D8
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE
/* End of the data section. */
#define GRUB_KERNEL_I386_PC_PREFIX_END (GRUB_KERNEL_I386_PC_PREFIX + 0x40)
/* The segment where the kernel is loaded. */
#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800
@ -65,7 +68,7 @@
#define GRUB_KERNEL_I386_QEMU_PREFIX 0x10
/* End of the data section. */
#define GRUB_KERNEL_I386_QEMU_DATA_END 0x50
#define GRUB_KERNEL_I386_QEMU_PREFIX_END 0x50
#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200
@ -82,7 +85,7 @@
#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX 0x14
/* End of the data section. */
#define GRUB_KERNEL_SPARC64_IEEE1275_DATA_END 0x114
#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END 0x114
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
@ -91,7 +94,7 @@
#define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END 0x44
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
@ -105,29 +108,29 @@
#define GRUB_KERNEL_MIPS_YEELOONG_KERNEL_IMAGE_SIZE 0x10
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE
#define GRUB_KERNEL_MIPS_YEELOONG_DATA_END GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE + 0x48
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE + 0x48
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_EFI_PREFIX 0x8
/* End of the data section. */
#define GRUB_KERNEL_I386_EFI_DATA_END 0x50
#define GRUB_KERNEL_I386_EFI_PREFIX_END 0x50
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_X86_64_EFI_PREFIX 0x8
/* End of the data section. */
#define GRUB_KERNEL_X86_64_EFI_DATA_END 0x50
#define GRUB_KERNEL_X86_64_EFI_PREFIX_END 0x50
#define GRUB_KERNEL_I386_COREBOOT_PREFIX 0x2
#define GRUB_KERNEL_I386_COREBOOT_DATA_END 0x42
#define GRUB_KERNEL_I386_COREBOOT_PREFIX_END 0x42
#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200
#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX GRUB_KERNEL_I386_COREBOOT_PREFIX
#define GRUB_KERNEL_I386_MULTIBOOT_DATA_END GRUB_KERNEL_I386_COREBOOT_DATA_END
#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END GRUB_KERNEL_I386_COREBOOT_PREFIX_END
#define GRUB_KERNEL_I386_IEEE1275_PREFIX 0x2
#define GRUB_KERNEL_I386_IEEE1275_DATA_END 0x42
#define GRUB_KERNEL_I386_IEEE1275_PREFIX_END 0x42
#define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000
#define GRUB_KERNEL_I386_IEEE1275_MOD_ALIGN 0x1000
@ -157,7 +160,7 @@
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _COMPRESSED_SIZE)
#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _PREFIX)
#define GRUB_KERNEL_MACHINE_DATA_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _DATA_END)
#define GRUB_KERNEL_MACHINE_PREFIX_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _PREFIX_END)
#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, MACHINE, _KERNEL_SEG)
#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, MACHINE, _UPPER)
#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _RAW_SIZE)

View file

@ -63,7 +63,7 @@ struct image_target_desc
PLATFORM_FLAGS_LZMA = 1
} flags;
unsigned prefix;
unsigned data_end;
unsigned prefix_end;
unsigned raw_size;
unsigned total_module_size;
unsigned kernel_image_size;
@ -86,7 +86,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_COREBOOT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
.data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
.prefix_end = GRUB_KERNEL_I386_COREBOOT_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -108,7 +108,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_COREBOOT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_MULTIBOOT_PREFIX,
.data_end = GRUB_KERNEL_I386_MULTIBOOT_DATA_END,
.prefix_end = GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -130,7 +130,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_I386_PC,
.flags = PLATFORM_FLAGS_LZMA,
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
.data_end = GRUB_KERNEL_I386_PC_DATA_END,
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
@ -148,7 +148,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_I386_PC_PXE,
.flags = PLATFORM_FLAGS_LZMA,
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
.data_end = GRUB_KERNEL_I386_PC_DATA_END,
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
@ -166,7 +166,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_EFI,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_EFI_PREFIX,
.data_end = GRUB_KERNEL_I386_EFI_DATA_END,
.prefix_end = GRUB_KERNEL_I386_EFI_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -188,7 +188,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_I386_IEEE1275,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
.data_end = GRUB_KERNEL_I386_IEEE1275_DATA_END,
.prefix_end = GRUB_KERNEL_I386_IEEE1275_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -210,7 +210,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_QEMU,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
.data_end = GRUB_KERNEL_I386_QEMU_DATA_END,
.prefix_end = GRUB_KERNEL_I386_QEMU_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.compressed_size = TARGET_NO_FIELD,
@ -228,7 +228,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_EFI,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
.data_end = GRUB_KERNEL_X86_64_EFI_DATA_END,
.prefix_end = GRUB_KERNEL_X86_64_EFI_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -250,7 +250,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_YEELOONG_FLASH,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
.data_end = GRUB_KERNEL_MIPS_YEELOONG_DATA_END,
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
.raw_size = GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE,
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
.compressed_size = GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE,
@ -270,7 +270,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_YEELOONG_ELF,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
.data_end = GRUB_KERNEL_MIPS_YEELOONG_DATA_END,
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
.raw_size = GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE,
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
.compressed_size = GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE,
@ -290,7 +290,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_PPC,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
.data_end = GRUB_KERNEL_POWERPC_IEEE1275_DATA_END,
.prefix_end = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END,
.raw_size = 0,
.total_module_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
@ -312,7 +312,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_SPARC64_RAW,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
.data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
@ -330,7 +330,7 @@ struct image_target_desc image_targets[] =
.id = IMAGE_SPARC64_AOUT,
.flags = PLATFORM_FLAGS_NONE,
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
.data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
@ -578,7 +578,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
total_module_size, &start_address, &rel_section,
&reloc_size, &align, image_target);
if (image_target->prefix + strlen (prefix) + 1 > image_target->data_end)
if (image_target->prefix + strlen (prefix) + 1 > image_target->prefix_end)
grub_util_error (_("prefix is too long"));
strcpy (kernel_img + image_target->prefix, prefix);