Fix support for Linux kernel images with no protected mode code
authorJosh Triplett <josh@joshtriplett.org>
Wed, 27 Mar 2013 21:50:37 +0000 (14:50 -0700)
committerMatt Fleming <matt.fleming@intel.com>
Mon, 8 Apr 2013 07:41:38 +0000 (08:41 +0100)
commitf16d2c170888fb416a7b376eb0a29dd3f7cced24
tree243e7666eb1055d2ce9999a42c3f890e983699eb
parent66d551acdb0d516f43702983184483687c2128e4
Fix support for Linux kernel images with no protected mode code

Some kernel images use the Linux kernel boot protocol and header
structure, but do not actually have any protected-mode code.  For
instance, grub's 1024-byte lnxboot.img consists of 1024 real-mode bytes
and 0 protected-mode bytes; you can concatenate it with a full grub
core.img to produce a self-contained bootable kernel, but you can also
use it standalone as the kernel with the core.img loaded as an initrd.

syslinux 4 supports this, but it no longer works with syslinux 5: the
memmap functions do not correctly handle a request to work with a 0-byte
region.  With lnxboot.img, this would cause syslinux to bail because it
thinks it has no space at the 1M load location but cannot relocate
lnxboot.img.  (In bailing, it gives the confusing error message "Bad
file descriptor", not because that error actually occurred when
attempting to boot the kernel, but because errno has that value on entry
to syslinux_boot_linux and nothing clears or sets it.)

Fix the regression by handling the corner case of no protected-mode code
explicitly.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Burt Triplett <burt@pbjtriplett.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/lib/syslinux/load_linux.c