core: Shrink core/ldlinux.sys to be under 64K bytes
authorMatt Fleming <matt.fleming@intel.com>
Tue, 20 Mar 2012 16:27:17 +0000 (16:27 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 23 Mar 2012 16:34:41 +0000 (16:34 +0000)
commita0ff1769893dc47028694ee51824bf681672876c
tree8ef42db23b29ac15055cd1eb6c42f9b8871c6335
parent65377fc66c4e0877a9bcc511cdc92b5a05e23822
core: Shrink core/ldlinux.sys to be under 64K bytes

It would seem that running from a btrfs file system has been broken
for some time. The reason is that core/ldlinux.sys has grown
substantially, resulting in it weighing in at a whopping 88K bytes and
no longer fitting within the first 64K segment of a btrfs file system.

This huge size stems from the fact that the core links with
libcom32min.a because it requires various symbols contained within
that archive but it includes and exports *all* the symbols from
libcom32min.a. The reasoning behind this design decision is that when
a module is loaded any undefined symbols that are defined in
libcom32min.a can be resolved at runtime by the core, without the
module also needing to statically link against libcom32min.a.
Unfortunately doing this has increased the size of the core beyond
acceptable limits, such that booting from a btrfs file system no
longer works.

This commit links ldlinux.c32 against libcom32min.a so that now
ldlinux.c32 exports all the symbols contained within the
archive. Since we will always load ldlinux.c32 before any other
modules, any undefined symbols will now be resolved by ldlinux.c32
instead of the core. ldlinux.c32 isn't subject to same size
constraints as the core, e.g. fitting within 64K.

Here are the sizes in bytes before and after this commit,

Before:
        33806   com32/elflink/ldlinux/ldlinux.c32
        87749   core/ldlinux.sys

After:
        393871  com32/elflink/ldlinux/ldlinux.c32
        45516   core/ldlinux.sys

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/Makefile
com32/elflink/ldlinux/Makefile
com32/lib/Makefile
core/Makefile