elflink: set the sonames of shared libraries

Set the sonames of shared libraries to the filename, so we don't end
up with full pathnames embedded in the files.
ldlinux: Don't delete ldlinux.c32 with 'make clean'

The documented command sequence for distributions wishing to package a
Syslinux release is,

	 make clean
	 make installer

Unfortunately, becaues ldlinux.c32 is deleted by 'make clean' the
installer target fails like so,

make[1]: *** No rule to make target `../com32/elflink/ldlinux/ldlinux.c32', needed by `ldlinuxc32_bin.c'.  Stop.
make: *** [installer] Error 2

Follow the example set by core/Makefile for ldlinux.sys, etc and add
any build files that are required by the installers to
$(BTARGET). $(BTARGET) only gets deleted when running 'make spotless'.

Reported-by: László Házy <hazy_l@yahoo.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
ldlinux: Dynamically alloc memory for kernel and initrd filenames

Absolutely no bounds checking is performed when copying filenames to
'cmdline_buf' and 'initrd_name' which means that sufficiently long
strings will scribble over the stack. At best, the files will simply
fail to load because the name is garbled.

Allocate space for the cmdline at runtime to avoid these overflow
problems.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
version: Bump minor number and year

Welcome to the 5.01 development cycle and 2013.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
core/kaboom.c: Export __bad_SEG()

We need to add __bad_SEG() to the symbol export whitelist, otherwise
ldlinux.c32 will fail to load if compiled with -DDEBUG=1 due to not
being able to resolve __bad_SEG().

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
menugen: Make it compatible with Py3k

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
extlinux: Make sure ldlinux.sys file is installed

Due to delayed allocation feature on XFS filesystems, a write is not
guaranteed to flushed out to the underlying file system after crash or
something else - so we need to make sure that ldlinux.sys is installed
correctly in the mounted filesystem.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
extlinux: Fix installation subdirectory patching

Commit a126f17f663c ("EXTLINUX: Initial XFS filesystem support") broke
the code that inserts the installation subdirectory into the Extended
Patch Area (EPA). The EPA entry is used to set the initial working
directory on boot.

This caused boot failures for users that chose an install directory
other than /boot/syslinux (technically, it failed for any path not in
'search_directories' in load_env32()) due to ldlinux.c32 failing to
load because the initial working directory was not set correctly.

Cc: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
module: Allow .c32 files to execute themselves

Historically, .c32 files had to explicitly link against ldlinux.c32 in
order to use its exported symbols. This lead to the undesirable
situation during module dependency resolution where loading,
e.g. menu.c32, would cause ldlinux.c32 to be reloaded, thus
re-executing its main() function and dropping the user at a prompt
instead of executing menu.c32.

commit 1357b7e62706 ("elflink: Don't reload the current EXEC_MODULE
module") was the solution to this problem, since you don't need to
reload a module to link against it's symbols. Unfortunately, while
this commit was intended to stop ldlinux.c32 being reloaded, it also
broke the use case where a .c32 wants to load itself, e.g. when
vesamenu.c32 wants to execute vesamenu.c32 with a different config.

Luckily, modules no longer need to include ldlinux.c32 in their
dependency list, since ldlinux.c32 is *always* loaded and any symbols
can be automatically resolved. Which means that the check in
spawn_load() can be deleted.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
isolinux: Update LBA in getlinsec loop

We need to increment the Logical Block Address in eax by the number of
sectors we passed to getlinsec after every invocation, otherwise we'll
start with the same sector everytime.

This bug was discovered when booting an isohybrid image, which failed
to boot after printing the following error,

    "Image checksum error, sorry..."

because the isolinux.bin was bigger than 32K, and thus invoked the
getlinsec loop that reads the file in chunks.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
PXELINUX: Fix IPAPPEND to include BOOTIF and SYSUUID

commit 14531c47bc95 ("core: Delete code that is duplicated in
ldlinux") erroneously deleted the BOOTIFStr and SYSUUIDStr entries
from the PXELINUX-version of IPAppends, meaning that IPAPPEND 3 and
IPAPPEND 4 didn't append the corresponding strings to the command
line.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
ldlinux: Strip whitespace from LABEL directive

Any LABEL directive arguments shouldn't include whitespace
characters. If whitespace characters are needed use MENU LABEL.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
module: Check return value of malloc()

And return NULL after printing an appropriate error message if the
call failed.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
ldlinux: Perform chdir() before parsing config

The old 4.x behaviour for handling CONFIG directives of the form,

    CONFIG foo.cfg /bar

was to lookup the absolute pathname of foo.cfg, then chdir to /bar and
finally to parse foo.cfg. The 5.x behaviour reversed the chdir and
parsing steps. This meant if foo.cfg's contents were simply,

    INCLUDE say.txt

4.x would include /bar/say.txt and 5.x would include
/boot/syslinux/say.txt (assuming the current working directory was
/boot/syslinux).

What's even worse is that because of the way 'config_cwd' is used in
5.x we'd actually perform the chdir() operation after the first
INCLUDE in foo.cfg, e.g.

   INCLUDE say.txt
   INCLUDE say.txt

would include /boot/syslinux/say.txt and /bar/say.txt, respectively.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
dos: obtain the executable pathname, cleanups

DOS actually does provide the fully qualified pathname to the
executable, which would be useful to make ldlinux.c32 data rather than
live inside the executable itself -- it has gotten too large.

Also, move some DOS internals -- inline functions only used inside the
dos directory -- out of libinstaller.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Always strip all the modules

Always strip the modules; they are too big unstripped.  Specifically,
we generate unstripped *.elf files, and then convert them to
stripped *.c32 files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Rename libutil_com.c32 to libutil.c32

Conform to 8.3 filenames for essential files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Rename libcom32gpl.c32 to libgpl.c32

Conform to 8.3 filenames for essential files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
bios.h: add missing dependent #include

io_delay() defined in bios.h depends on outb() defined in <sys/io.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/fs: remove some stale functions, inode refcount debug

Remove some stale (16-bit compatibility) functions in fs.c.

Add some debugging for inode refcounts.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>