[2551] 2009-08-30 Vladimir Serbinenko <[email protected]>

Vladimir Serbinenko <[email protected]> Sun, 30 Aug 2009 19:28:02 +0000
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2551
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2551
Author:   phcoder
Date:     2009-08-30 19:28:01 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
2009-08-30  Vladimir Serbinenko  <[email protected]>

	* loader/i386/bsdXX.c (SUFFIX (grub_freebsd_load_elfmodule)): Fix
	loading of headers in some cases.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/loader/i386/bsdXX.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-08-30 15:54:51 UTC (rev 2550)
+++ trunk/grub2/ChangeLog	2009-08-30 19:28:01 UTC (rev 2551)
@@ -1,3 +1,8 @@
+2009-08-30  Vladimir Serbinenko  <[email protected]>
+
+	* loader/i386/bsdXX.c (SUFFIX (grub_freebsd_load_elfmodule)): Fix
+	loading of headers in some cases.
+
 2009-08-30  Robert Millan  <[email protected]>
 
 	* configure.ac: Bump version to 1.97~beta1.

Modified: trunk/grub2/loader/i386/bsdXX.c
===================================================================
--- trunk/grub2/loader/i386/bsdXX.c	2009-08-30 15:54:51 UTC (rev 2550)
+++ trunk/grub2/loader/i386/bsdXX.c	2009-08-30 19:28:01 UTC (rev 2551)
@@ -197,15 +197,15 @@
   if (curload < module + sizeof (e))
     curload = module + sizeof (e);
 
-  load (file, UINT_TO_PTR (module + e.e_shoff), e.e_shoff,
+  load (file, UINT_TO_PTR (curload), e.e_shoff,
 	e.e_shnum * e.e_shentsize);
-  if (curload < module + e.e_shoff + e.e_shnum * e.e_shentsize)
-    curload = module + e.e_shoff + e.e_shnum * e.e_shentsize;
+  e.e_shoff = curload - module;
+  curload +=  e.e_shnum * e.e_shentsize;
 
-  load (file, UINT_TO_PTR (module + e.e_phoff), e.e_phoff,
+  load (file, UINT_TO_PTR (curload), e.e_phoff,
 	e.e_phnum * e.e_phentsize);
-  if (curload < module + e.e_phoff + e.e_phnum * e.e_phentsize)
-    curload = module + e.e_phoff + e.e_phnum * e.e_phentsize;
+  e.e_phoff = curload - module;
+  curload +=  e.e_phnum * e.e_phentsize;
 
   *kern_end = curload;