|
@@ -360,6 +360,13 @@ static int multiboot_load_raw ( struct image *image,
|
360
|
360
|
userptr_t buffer;
|
361
|
361
|
int rc;
|
362
|
362
|
|
|
363
|
+ /* Sanity check */
|
|
364
|
+ if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
|
|
365
|
+ DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
|
|
366
|
+ image );
|
|
367
|
+ return -EINVAL;
|
|
368
|
+ }
|
|
369
|
+
|
363
|
370
|
/* Verify and prepare segment */
|
364
|
371
|
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
|
365
|
372
|
filesz = ( hdr->mb.load_end_addr ?
|
|
@@ -432,14 +439,14 @@ static int multiboot_load ( struct image *image ) {
|
432
|
439
|
return -ENOTSUP;
|
433
|
440
|
}
|
434
|
441
|
|
435
|
|
- /* Load the actual image */
|
436
|
|
- if ( hdr.mb.flags & MB_FLAG_RAW ) {
|
437
|
|
- if ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 )
|
438
|
|
- return rc;
|
439
|
|
- } else {
|
440
|
|
- if ( ( rc = multiboot_load_elf ( image ) ) != 0 )
|
441
|
|
- return rc;
|
442
|
|
- }
|
|
442
|
+ /* There is technically a bit MB_FLAG_RAW to indicate whether
|
|
443
|
+ * this is an ELF or a raw image. In practice, grub will use
|
|
444
|
+ * the ELF header if present, and Solaris relies on this
|
|
445
|
+ * behaviour.
|
|
446
|
+ */
|
|
447
|
+ if ( ( ( rc = multiboot_load_elf ( image ) ) != 0 ) &&
|
|
448
|
+ ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
|
|
449
|
+ return rc;
|
443
|
450
|
|
444
|
451
|
return 0;
|
445
|
452
|
}
|