2002-05-23 Yoshinori K. Okuji <okuji@enbug.org>

Define the behavior of the boot loader when the load end address
	and the bss end address are zero in the Multiboot Specification,
	and add the support into GRUB. I've modified a patch from Yuri
	Zaporogets <yuriz@ukr.net>.

	* stage2/boot.c (load_image): In the case of Multiboot a.out
	kludge, set the load end address to the load address plus the
	size of the OS image file, if it is zero. Similarly, set the bss
	end address to the load end address, if it is zero.

	* util/mbchk.c (check_multiboot): Don't check if the load
	address is greater than or equal to the load end address, if the
	load end address is zero. Don't check if the load end address is
	greater than the bss end address, if the bss end address is
	zero. And, don't check if the load end address is less than or
	equal to the entry address, if the load end address is zero.

	* docs/multiboot.texi (The address fields of Multiboot header):
	Added descriptions about the behavior of the boot loader when
	LOAD_END_ADDR is zero and BSS_END_ADDR is zero.
This commit is contained in:
okuji 2002-05-22 17:08:37 +00:00
parent f90c3eaf90
commit b225b42f05
5 changed files with 48 additions and 5 deletions

View file

@ -1,3 +1,26 @@
2002-05-23 Yoshinori K. Okuji <okuji@enbug.org>
Define the behavior of the boot loader when the load end address
and the bss end address are zero in the Multiboot Specification,
and add the support into GRUB. I've modified a patch from Yuri
Zaporogets <yuriz@ukr.net>.
* stage2/boot.c (load_image): In the case of Multiboot a.out
kludge, set the load end address to the load address plus the
size of the OS image file, if it is zero. Similarly, set the bss
end address to the load end address, if it is zero.
* util/mbchk.c (check_multiboot): Don't check if the load
address is greater than or equal to the load end address, if the
load end address is zero. Don't check if the load end address is
greater than the bss end address, if the bss end address is
zero. And, don't check if the load end address is less than or
equal to the entry address, if the load end address is zero.
* docs/multiboot.texi (The address fields of Multiboot header):
Added descriptions about the behavior of the boot loader when
LOAD_END_ADDR is zero and BSS_END_ADDR is zero.
2002-05-22 Yoshinori K. Okuji <okuji@enbug.org>
* stage2/builtins.c (boot_func): If DEBUG is true, print

5
NEWS
View file

@ -1,5 +1,10 @@
NEWS - list of user-visible changes between releases of GRUB
New in 0.93:
* Define the behavior of the boot loader when the load end address is
zero and the bss end address is zero in the Multiboot Specification.
Also, add the support into GRUB.
New in 0.92 - 2002-04-30:
* The command "displaymem" uses only hex digits for consistency.
* The netboot code goes back to the progress bars instead of dots, for

View file

@ -467,12 +467,15 @@ Contains the physical address of the end of the data
segment. (load_end_addr - load_addr) specifies how much data to load.
This implies that the text and data segments must be consecutive in the
OS image; this is true for existing a.out executable formats.
If this field is zero, the boot loader assumes that the text and data
segments occupy the whole OS image file.
@item bss_end_addr
Contains the physical address of the end of the bss segment. The boot
loader initializes this area to zero, and reserves the memory it
occupies to avoid placing boot modules and other data relevant to the
operating system in that area.
operating system in that area. If this field is zero, the boot loader
assumes that no bss segment is present.
@item entry_addr
The physical address to which the boot loader should jump in order to

View file

@ -141,8 +141,18 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
cur_addr = pu.mb->load_addr;
/* first offset into file */
grub_seek (i - (pu.mb->header_addr - cur_addr));
/* If the load end address is zero, load the whole contents. */
if (! pu.mb->load_end_addr)
pu.mb->load_end_addr = cur_addr + filemax;
text_len = pu.mb->load_end_addr - cur_addr;
data_len = 0;
/* If the bss end address is zero, assume that there is no bss area. */
if (! pu.mb->bss_end_addr)
pu.mb->bss_end_addr = pu.mb->load_end_addr;
bss_len = pu.mb->bss_end_addr - pu.mb->load_end_addr;
if (pu.mb->header_addr < pu.mb->load_addr

View file

@ -1,6 +1,6 @@
/* mbchk - a simple checker for the format of a Multiboot kernel */
/*
* Copyright (C) 1999, 2001 Free Software Foundation, Inc.
* Copyright (C) 1999,2001,2002 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -126,7 +126,7 @@ check_multiboot (const char *filename, FILE *fp)
return 0;
}
if (mbh->load_addr >= mbh->load_end_addr)
if (mbh->load_end_addr && mbh->load_addr >= mbh->load_end_addr)
{
fprintf (stderr,
"%s: load_addr is not less than load_end_addr"
@ -135,7 +135,7 @@ check_multiboot (const char *filename, FILE *fp)
return 0;
}
if (mbh->load_end_addr > mbh->bss_end_addr)
if (mbh->bss_end_addr && mbh->load_end_addr > mbh->bss_end_addr)
{
fprintf (stderr,
"%s: load_end_addr is greater than bss_end_addr"
@ -153,7 +153,9 @@ check_multiboot (const char *filename, FILE *fp)
return 0;
}
if (mbh->load_end_addr <= mbh->entry_addr)
/* FIXME: It is better to check if the entry address is within the
file, especially when the load end address is zero. */
if (mbh->load_end_addr && mbh->load_end_addr <= mbh->entry_addr)
{
fprintf (stderr,
"%s: load_end_addr is not less than entry_addr"