Hi,

cleanupmsg.diff changes the "(cleaned up) New segment.." message to be
displayed only when the condition happens.

properzero.diff changes the memset to only clean up the area which is
not memcopied to.

--
Alex

Index: elfboot.c
===================================================================
--- elfboot.c	(revision 486)
+++ elfboot.c	(working copy)
@@ -103,11 +103,11 @@
 			phdr[i].p_paddr, phdr[i].p_memsz, phdr[i].p_offset, phdr[i].p_filesz);
 		/* Clean up the values */
 		size = phdr[i].p_filesz;
-		if (phdr[i].p_filesz > phdr[i].p_memsz)  {
+		if (size > phdr[i].p_memsz)  {
 			size = phdr[i].p_memsz;
+			printk(BIOS_DEBUG, "(cleaned up) New segment addr 0x%x size 0x%x offset 0x%x\n",
+			    phdr[i].p_paddr, size, phdr[i].p_offset);
 		}
-		printk(BIOS_DEBUG, "(cleaned up) New segment addr 0x%x size 0x%x offset 0x%x\n",
-			phdr[i].p_paddr, size, phdr[i].p_offset);
 
 		/* Verify the memory addresses in the segment are valid */
 		if (!valid_area(mem, phdr[i].p_paddr, size)) 
Index: elfboot.c
===================================================================
--- elfboot.c	(revision 486)
+++ elfboot.c	(working copy)
@@ -112,16 +112,13 @@
 		/* Verify the memory addresses in the segment are valid */
 		if (!valid_area(mem, phdr[i].p_paddr, size)) 
 			goto out;
-		/* let's just be stupid about this. Bzero the whole area we are copying to, 
-		  * then copy out the data, which may be a subset of the total area. 
-		  * the cache, after all, is your friend.
-		  */
-		printk(BIOS_INFO, "Set %p to 0 for %d bytes\n", (unsigned char *)phdr[i].p_paddr, phdr[i].p_memsz);
-		memset((unsigned char *)phdr[i].p_paddr, 0, phdr[i].p_memsz);
 		/* ok, copy it out */
 		printk(BIOS_INFO, "Copy to %p from %p for %d bytes\n", (unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size);
 		memcpy((unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size);
-		
+		if (size < phdr[i].p_memsz) {
+		        printk(BIOS_INFO, "Set %p to 0 for %d bytes\n", (unsigned char *)phdr[i].p_paddr, phdr[i].p_memsz-size);
+		        memset((unsigned char *)phdr[i].p_paddr+size, 0, phdr[i].p_memsz-size);
+		}
 	}
 	return 1;
  out:
-- 
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to