Raphael S.Carvalho
2013-Jul-24 11:05 UTC
[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.
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 diff --git a/core/Makefile b/core/Makefile index f795a5c..00de331 100644 --- a/core/Makefile +++ b/core/Makefile @@ -220,8 +220,9 @@ ldlinux.bss: ldlinux.bin dd if=$< of=$@ bs=512 count=1 ldlinux.sys: ldlinux.bin - dd if=$< of=$@ bs=512 skip=2 - + $(PERL) $(SRC)/ldlinux_limit.pl $< \ + dd if=$< of=$@ bs=512 skip=2; + codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp cp -f $< $@ diff --git a/core/ldlinux_limit.pl b/core/ldlinux_limit.pl new file mode 100644 index 0000000..61f4823 --- /dev/null +++ b/core/ldlinux_limit.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl +## ----------------------------------------------------------------------- +## +## Copyright 2013 Raphael S. Carvalho <raphael.scarv at gmail.com> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, +## Boston MA 02111-1307, USA; either version 2 of the License, or +## (at your option) any later version; incorporated herein by reference. +## +## ----------------------------------------------------------------------- + +## ldlinux_limit.pl: Calc the size of ldlinux.sys and check if it's larger than 64k. + +use File::stat; + +($ldlinux_bin) = @ARGV; +$limit = 65536; +$pad = 512; + +$ldlinux_size = stat($ldlinux_bin)->size - 1024; +$align = $ldlinux_size % $pad; +$ldlinux_size += $pad - $align; + +if ($ldlinux_size > $limit) { + print STDERR "$0: ldlinux.sys ($ldlinux_size) larger than $limit.\n"; + exit 1; +} + +exit 0; -- 1.7.2.5
Matt Fleming
2013-Jul-26 15:10 UTC
[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.
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.plThanks, 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. -- Matt Fleming, Intel Open Source Technology Center
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
Maybe Matching 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: Check if ldlinux.sys exceeds the limit at its building 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.