H. Peter Anvin
2013-Jul-26 19:58 UTC
[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.
On 07/26/2013 08:10 AM, Matt Fleming wrote:> On Wed, 24 Jul, at 08:05:16AM, Raphael S.Carvalho wrote: >> Check if ldlinux.sys is larger than 64k at build time. >> >> Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com> >> --- >> core/Makefile | 5 +++-- >> core/ldlinux_limit.pl | 31 +++++++++++++++++++++++++++++++ >> 2 files changed, 34 insertions(+), 2 deletions(-) >> create mode 100644 core/ldlinux_limit.pl > > Thanks, this looks good, though the patch was whitespace damaged. I also > expanded on the commit message to explain *why* 64K is the limit we use. > > I'll push this out once I've shrunk ldlinux.sys down to size. >The test is wrong: we need it to fit into 64K *including* the boot sector and two copies of the ADV. Currently the ADV is 512 bytes, but we probably need to make it 4K. -hpa
Raphael S Carvalho
2013-Jul-26 20:36 UTC
[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.
On Fri, Jul 26, 2013 at 4:58 PM, H. Peter Anvin <hpa at zytor.com> wrote:> On 07/26/2013 08:10 AM, Matt Fleming wrote: > > On Wed, 24 Jul, at 08:05:16AM, Raphael S.Carvalho wrote: > >> Check if ldlinux.sys is larger than 64k at build time. > >> > >> Signed-off-by: Raphael S.Carvalho <raphael.scarv at gmail.com> > >> --- > >> core/Makefile | 5 +++-- > >> core/ldlinux_limit.pl | 31 +++++++++++++++++++++++++++++++ > >> 2 files changed, 34 insertions(+), 2 deletions(-) > >> create mode 100644 core/ldlinux_limit.pl > > > > Thanks, this looks good, though the patch was whitespace damaged. I also > > expanded on the commit message to explain *why* 64K is the limit we use. > > > > I'll push this out once I've shrunk ldlinux.sys down to size. > > > > The test is wrong: we need it to fit into 64K *including* the boot > sector and two copies of the ADV. Currently the ADV is 512 bytes, but > we probably need to make it 4K. > > -hpa > >Bootsector is installed into the 0-512 range, whereas 2 copies of ADV into (65536 - 2 * ADV_SIZE). Then basically ldlinux.sys must fit between the bootsector and two copies of ADV whose size may vary. The range 0-64k is laid out something like this, right?! [0](bootsector)[512](ldlinux.sys)[65536 - 2 * ADV_SIZE](2 copies of ADV)[65536] If so, the size of ldlinux.sys can be at most: 65536 - 2 * ADV_SIZE - 512. If ADV_SIZE change from 512 to 4k, it will be difficult to install ldlinux.sys at the 0-64k range of a BTRFS image. Regards, Raphael S. Carvalho.
H. Peter Anvin
2013-Jul-26 20:42 UTC
[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.
On 07/26/2013 01:36 PM, Raphael S Carvalho wrote:> > Bootsector is installed into the 0-512 range, whereas 2 copies of ADV > into (65536 - 2 * ADV_SIZE). > Then basically ldlinux.sys must fit between the bootsector and two > copies of ADV whose size may vary. > > The range 0-64k is laid out something like this, right?! > [0](bootsector)[512](ldlinux.sys)[65536 - 2 * ADV_SIZE](2 copies of > ADV)[65536] > > If so, the size of ldlinux.sys can be at most: 65536 - 2 * ADV_SIZE - 512. > If ADV_SIZE change from 512 to 4k, it will be difficult to install > ldlinux.sys at the 0-64k range of a BTRFS image. >That is correct. We may have to do something like Grub's "stage 1.5", a totally stripped down version of ldlinux.sys containing just enough to load the real ldlinux.sys from the filesystem. Sigh. -hpa
Seemingly Similar Threads
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
- [PATCH v2] core: Check size of ldlinux.sys at building time.
- [PATCH 1/1] core: Add a check at ldlinux.sys build time.
- [PATCH 1/1] core: Check if ldlinux.sys exceeds the limit at its building time.
- [PATCH 1/1] core: Add a check at ldlinux.sys build time.