summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2008-09-06 02:57:25 +0200
committerMichael Brown2008-09-06 02:57:52 +0200
commit2e03610c0d6840aab412e2c2be554453bfd99eb5 (patch)
treebe4847d8ff6257f3a676b8f11781e3fa9ac7602d
parent[util] Avoid calling fclose(NULL) in zbin.c (diff)
downloadipxe-2e03610c0d6840aab412e2c2be554453bfd99eb5.tar.gz
ipxe-2e03610c0d6840aab412e2c2be554453bfd99eb5.tar.xz
ipxe-2e03610c0d6840aab412e2c2be554453bfd99eb5.zip
[multiboot] Allow for unspecified {load,bss}_end_addr for raw images
The multiboot specification states that, for raw images, if load_end_addr is zero then it should be interpreted as meaning "use the entire file", and if bss_end_addr is zero it should be interpreted as meaning "no bss".
-rw-r--r--src/arch/i386/image/multiboot.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c
index 3aa52e43..a4a340fd 100644
--- a/src/arch/i386/image/multiboot.c
+++ b/src/arch/i386/image/multiboot.c
@@ -360,8 +360,11 @@ static int multiboot_load_raw ( struct image *image,
/* Verify and prepare segment */
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
- filesz = ( hdr->mb.load_end_addr - hdr->mb.load_addr );
- memsz = ( hdr->mb.bss_end_addr - hdr->mb.load_addr );
+ filesz = ( hdr->mb.load_end_addr ?
+ ( hdr->mb.load_end_addr - hdr->mb.load_addr ) :
+ ( image->len - offset ) );
+ memsz = ( hdr->mb.bss_end_addr ?
+ ( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
buffer = phys_to_user ( hdr->mb.load_addr );
if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n",