Browse Source

[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".
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
2e03610c0d
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/arch/i386/image/multiboot.c

+ 5
- 2
src/arch/i386/image/multiboot.c View File

@@ -360,8 +360,11 @@ static int multiboot_load_raw ( struct image *image,
360 360
 
361 361
 	/* Verify and prepare segment */
362 362
 	offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
363
-	filesz = ( hdr->mb.load_end_addr - hdr->mb.load_addr );
364
-	memsz = ( hdr->mb.bss_end_addr - hdr->mb.load_addr );
363
+	filesz = ( hdr->mb.load_end_addr ?
364
+		   ( hdr->mb.load_end_addr - hdr->mb.load_addr ) :
365
+		   ( image->len - offset ) );
366
+	memsz = ( hdr->mb.bss_end_addr ?
367
+		  ( hdr->mb.bss_end_addr - hdr->mb.load_addr ) : filesz );
365 368
 	buffer = phys_to_user ( hdr->mb.load_addr );
366 369
 	if ( ( rc = prep_segment ( buffer, filesz, memsz ) ) != 0 ) {
367 370
 		DBGC ( image, "MULTIBOOT %p could not prepare segment: %s\n",

Loading…
Cancel
Save