Patchwork ldscript_fallback_cbs.lb and 4G files

login
register
about
Submitter Maciej Pijanka
Date 2009-12-01 14:24:53
Message ID <20091201142453.GA2204@debshine>
Download mbox | patch
Permalink /patch/618/
State Rejected
Headers show

Comments

Maciej Pijanka - 2009-12-01 14:24:53
Hello

Sorry for troubles caused by my ldscript patch that triggered slightly
misbehaviour resulting in 4GB image files in abuild. I didn't noticed
such behaviour on my machine and thats why i send it to ML.

I created separated from ld way to reuse space in top 64k not used by bootblock
patch in attachment. Only missing thing in this patch would be option to enable
firing script that calculates size that can be claimed and adjusting gapsize
so it might be disabled by default.

Signed-off: Maciej Pijanka <maciej.pijanka@gmail.com>
(or should i add Blames-To: also?)

best regards
Maciej

Patch

Index: util/compute_gapsize
===================================================================
--- util/compute_gapsize	(revision 0)
+++ util/compute_gapsize	(revision 0)
@@ -0,0 +1,55 @@ 
+#!/usr/bin/perl -w
+use strict;
+# 
+# This file is part of the coreboot project.
+#
+# Copyright (C) 2009 Maciej Pijanka <maciej.pijanka@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; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+use warnings;
+
+
+my $file = shift @ARGV || die "Give me an elf file name";
+
+die "No such file: $!" unless (-e $file);
+
+my $GAP = 0;
+
+my $SIZE = 0;
+
+open IN,'readelf -W -S '.$file.'|';
+while (not eof IN) {
+	my $line = <IN>;
+	chomp $line;
+
+	next unless ($line =~ /^ *\[ *[0-9]+\] ([\.a-z]+) *[A-Z]+ *([0-9a-f]+) ([0-9a-f]+) ([0-9a-f]+) [0-9a-f]{2} /);
+
+	my ($name, $start, $off, $len) = ($1, hex $2, hex $3, hex $4);
+
+	next unless ($name eq '.rom' or $name eq '.text' or $name eq '.id');
+
+	if (($start & 0x0F) != 0) {
+		my $shift = $start & 0x0F;
+		printf STDERR "Section %s aligned to 16byte boundary (%d bytes added)\n", $name, $shift;
+		$len += $shift;
+		$start -= $shift;
+	}
+
+	#printf "%s %x %x %x\n", $name, $start, $off, $len;
+	$SIZE += $len;
+}
+close IN;
+
+printf "CONFIG_GAPSIZE = 0x%x;\n", 0x0000fff0 - $SIZE; 

Property changes on: util/compute_gapsize
___________________________________________________________________
Added: svn:executable
   + *

Index: src/arch/i386/init/ldscript_fallback_cbfs.lb
===================================================================
--- src/arch/i386/init/ldscript_fallback_cbfs.lb	(revision 4971)
+++ src/arch/i386/init/ldscript_fallback_cbfs.lb	(working copy)
@@ -38,7 +38,7 @@ 
 
 	/* cut _start into last 64k*/
 	_x = .;
-	. = (_x < (CONFIG_ROMBASE - 0x10000 +  CONFIG_ROM_IMAGE_SIZE)) ? (CONFIG_ROMBASE - 0x10000 +  CONFIG_ROM_IMAGE_SIZE) : _x;
+	. = ((_x < (CONFIG_ROMBASE - 0x10000 +  CONFIG_ROM_IMAGE_SIZE)) ? (CONFIG_ROMBASE - 0x10000 +  CONFIG_ROM_IMAGE_SIZE) : _x) + CONFIG_GAPSIZE;
 
 	/* This section might be better named .setup */
 	.rom . : {
Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc	(revision 4971)
+++ src/arch/i386/Makefile.inc	(working copy)
@@ -43,6 +43,7 @@ 
 
 $(obj)/ldscript.ld: $(ldscripts) $(obj)/ldoptions
 	printf 'INCLUDE "ldoptions"\n' > $@
+	printf 'INCLUDE "ldgap"\n' >> $@
 	printf '$(foreach ldscript,$(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@
 
 $(obj)/crt0_includes.h: $(crt0s)
@@ -56,7 +57,10 @@ 
 
 $(obj)/coreboot: $(initobjs) $(obj)/ldscript.ld
 	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
+	printf 'CONFIG_GAPSIZE = 0;\n' > $(obj)/ldgap
 	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/ldscript.ld $(initobjs)
+	./util/compute_gapsize $@ > $(obj)/ldgap
+	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/ldscript.ld $(initobjs)
 	$(NM) -n $(obj)/coreboot | sort > $(obj)/coreboot.map
 
 #######################################################################