[LinuxBIOS] r498 - LinuxBIOSv3/util/lar

svn at openbios.org svn at openbios.org
Sun Sep 16 16:37:59 CEST 2007

Author: uwe
Date: 2007-09-16 16:37:59 +0200 (Sun, 16 Sep 2007)
New Revision: 498

When outputting ELF segments in LAR, the utility will use the segment
number from ELF as segment number in the file. This works nicely when
there are no skips (e.g. not PT_LOAD segments, which are discarded).

If one segment is skipped, we get a bump:

normal/payload0/segment0 (27288 bytes, lzma compressed to 14506 bytes @0x64c0)
normal/payload0/segment2 (211136 bytes, lzma compressed to 70905 bytes @0x9dc0)

The LAR loader wont load segment2, and in this particular case, grub2-lb
will only boot into rescue mode (segment0 contains it).

Attached patch adds a counter for segment number in the LAR utility to
solve this bug:

normal/payload0/segment0 (27288 bytes, lzma compressed to 14506 bytes @0x64c0)
normal/payload0/segment1 (211136 bytes, lzma compressed to 70905 bytes @0x9dc0)

Also the eagle eyed can see that I merged in Uwe's multiple-payload
patch into current stage1, which includes the segment support. And this
means that grub2-lb without any hacks works when loaded from LAR segments.

Signed-off-by: Alex Beregszaszi <alex at rtfs.hu>
Acked-by: Ronald G. Minnich <rminnich at gmail.com>
Acked-by: Uwe Hermann <uwe at hermann-uwe.de>

Modified: LinuxBIOSv3/util/lar/stream.c
--- LinuxBIOSv3/util/lar/stream.c	2007-09-16 14:32:26 UTC (rev 497)
+++ LinuxBIOSv3/util/lar/stream.c	2007-09-16 14:37:59 UTC (rev 498)
@@ -79,6 +79,7 @@
 	u32 entry;
 	int i;
 	int size;
+	int segment = 0;
 	char *header;
 	char ename[64];
 	int headers;
@@ -153,7 +154,7 @@
 				entry,  phdr[i].p_paddr);
 			/* ok, copy it out */
-		sprintf(ename, "%s/segment%d", name, i);
+		sprintf(ename, "%s/segment%d", name, segment++);
 		complen = lar_compress(&header[phdr[i].p_offset], size, temp, &thisalgo);
 		ret = lar_add_entry(lar, ename, temp, complen, size, 
 				    phdr[i].p_paddr, entry, thisalgo);

More information about the coreboot mailing list