diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-03-26 15:27:00 -0400 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-05-29 20:19:24 -0500 |
commit | 9c3a596a03cc10c2d9097f057b9ccb9d557a4d5f (patch) | |
tree | 32dd3d1afcf98f9bd08a901a2aff073dbe5678e8 | |
parent | 8294a64d7f9ecc428cd58ba36ad0b913084a8824 (diff) | |
download | qemu-9c3a596a03cc10c2d9097f057b9ccb9d557a4d5f.zip qemu-9c3a596a03cc10c2d9097f057b9ccb9d557a4d5f.tar.gz qemu-9c3a596a03cc10c2d9097f057b9ccb9d557a4d5f.tar.bz2 |
fix multiboot loading if load_end_addr == 0
The previous multiboot load code did not treat the case where
load_end_addr was 0 specially. The multiboot specification says the
following:
* load_end_addr
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.
Signed-off-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/multiboot.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/hw/multiboot.c b/hw/multiboot.c index b4484a3..b1e04c5 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -202,10 +202,16 @@ int load_multiboot(void *fw_cfg, uint32_t mh_bss_end_addr = ldl_p(header+i+24); mh_load_addr = ldl_p(header+i+16); uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr); - uint32_t mb_load_size = mh_load_end_addr - mh_load_addr; - + uint32_t mb_load_size = 0; mh_entry_addr = ldl_p(header+i+28); - mb_kernel_size = mh_bss_end_addr - mh_load_addr; + + if (mh_load_end_addr) { + mb_kernel_size = mh_bss_end_addr - mh_load_addr; + mb_load_size = mh_load_end_addr - mh_load_addr; + } else { + mb_kernel_size = kernel_file_size - mb_kernel_text_offset; + mb_load_size = mb_kernel_size; + } /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. uint32_t mh_mode_type = ldl_p(header+i+32); |