[syslinux] [PATCH 1/1] core: Add a check at ldlinux.sys build time.

Raphael S.Carvalho raphael.scarv at gmail.com
Wed Jul 24 04:05:16 PDT 2013


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



More information about the Syslinux mailing list