Patchwork another attempt at minimizing bootblock size

login
register
about
Submitter Patrick Georgi
Date 2010-02-23 13:11:50
Message ID <4B83D416.1060401@georgi-clan.de>
Download mbox | patch
Permalink /patch/959/
State Accepted
Headers show

Comments

Patrick Georgi - 2010-02-23 13:11:50
Hi,

attached patch is another attempt at minimizing bootblock size.
It also removes the obsolete ldscript_cbfs.lb, and removes any mention
of _lrom and _elrom, which were set but never used (and broke the
minimization approach used)

With the patch, the bootblock for kontron/986lcd-m is just 978 bytes,
the bootblock for amd/serengeti_cheetah_fam10 is 2390 bytes (more
complex setup), and asus/m2v-mx_se features a bootblock of 674 bytes.

I only did that for the tinybootblock variant of building images, as
it's much easier and thus safer to handle.

I also added a memory region constraint, so ld fails once the bootblock
is more than 64k, which will be most effective to guards against the
close-to-4GB images we've seen every once in a while.
However, this might require some tweaking of the list of discarded
sections, as ld complains about the various "default" sections, even if
those are empty and would be discarded in any case.

Those files should also be renamed at some point (no need to mention
that the file is for "CBFS", and .lb should be called .cb), but I'd
prefer to do that after I moved away the ldscripts variable in the build
system, so there are fewer files to touch for that.


Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Peter Stuge - 2010-02-23 19:14:26
> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>

Acked-by: Peter Stuge <peter@stuge.se>

Patch

Index: src/arch/i386/init/ldscript_failover.lb
===================================================================
--- src/arch/i386/init/ldscript_failover.lb	(revision 5130)
+++ src/arch/i386/init/ldscript_failover.lb	(working copy)
@@ -27,33 +27,34 @@ 
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
 
-/*
-ENTRY(_start)
-*/
+MEMORY {
+	rom : ORIGIN = 0xffff0000, LENGTH = 64K
+}
 
 TARGET(binary)
 SECTIONS
 {
-	. = CONFIG_ROMBASE;
+	. = 0;
 
 	/* This section might be better named .setup */
-	.rom . : {
+	.rom ROMLOC : {
 		_rom = .;
 		*(.rom.text);
 		*(.rom.data);
 		*(.rom.data.*);
 		*(.rodata.*);
-		. = ALIGN(16);
 		_erom = .;
-	}
+	} >rom =0xff
 
-	_lrom = LOADADDR(.rom);
-	_elrom = LOADADDR(.rom) + SIZEOF(.rom);
+	ROMLOC = 0xffffff00 - (_erom - _rom) + 1;
 
 	/DISCARD/ : {
 		*(.comment)
 		*(.note)
 		*(.comment.*)
 		*(.note.*)
+		*(.iplt)
+		*(.rel.*)
+		*(.igot.*)
 	}
 }
Index: src/arch/i386/init/ldscript_fallback_cbfs.lb
===================================================================
--- src/arch/i386/init/ldscript_fallback_cbfs.lb	(revision 5130)
+++ src/arch/i386/init/ldscript_fallback_cbfs.lb	(working copy)
@@ -53,9 +53,6 @@ 
 		_erom = .;
 	}
 
-	_lrom = LOADADDR(.rom);
-	_elrom = LOADADDR(.rom) + SIZEOF(.rom);
-
 	/DISCARD/ : {
 		*(.comment)
 		*(.note)
Index: src/arch/i386/init/ldscript_cbfs.lb
===================================================================
--- src/arch/i386/init/ldscript_cbfs.lb	(revision 5130)
+++ src/arch/i386/init/ldscript_cbfs.lb	(working copy)
@@ -1,59 +0,0 @@ 
-/*
- *	Memory map:
- *
- *	CONFIG_RAMBASE		
- *				: data segment
- *				: bss segment
- *				: heap
- *				: stack
- *	CONFIG_ROMBASE
- *				: coreboot text 
- *				: readonly text
- */
-/*
- * Bootstrap code for the STPC Consumer
- * Copyright (c) 1999 by Net Insight AB. All Rights Reserved.
- *
- */
-
-/*
- *	Written by Johan Rydberg, based on work by Daniel Kahlin.
- *      Rewritten by Eric Biederman
- */
-/*
- *	We use ELF as output format. So that we can
- *	debug the code in some form. 
- */
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-
-/*
-ENTRY(_start)
-*/
-
-TARGET(binary)
-SECTIONS
-{
-	. = CONFIG_ROMBASE;
-
-	/* This section might be better named .setup */
-	.rom . : {
-		_rom = .;
-		*(.rom.text);
-		*(.rom.data);
-		*(.rodata.*);
-		*(.rom.data.*);
-		. = ALIGN(16);
-		_erom = .;
-	}
-
-	_lrom = LOADADDR(.rom);
-	_elrom = LOADADDR(.rom) + SIZEOF(.rom);
-
-	/DISCARD/ : {
-		*(.comment)
-		*(.comment.*)
-		*(.note)
-		*(.note.*)
-	}
-}