]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 11 Jan 2011 22:01:07 +0000 (23:01 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 11 Jan 2011 22:01:07 +0000 (23:01 +0100)
loadmask before doing any calculations. Use correct type for offset.
(grub_linux_load64): Likewise.

ChangeLog
grub-core/loader/powerpc/ieee1275/linux.c

index 56a8db213685a0a394e85cbb72a97f2f2fd1074b..05e2ec8c75b3642041545a608c46b43165a6d706 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-11  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply
+       loadmask before doing any calculations. Use correct type for offset.
+       (grub_linux_load64): Likewise.
+
 2011-01-11  Colin Watson  <cjwatson@ubuntu.com>
 
        * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate
index a99310cfda727b2b7e0e1b93bef07c54d495b4ac..0cf0eb825b39e46c6e6d9dfe52e0f6b51868e61b 100644 (file)
@@ -152,7 +152,8 @@ grub_linux_load32 (grub_elf_t elf)
   Elf32_Addr base_addr;
   grub_addr_t seg_addr;
   grub_uint32_t align;
-  int offset;
+  grub_uint32_t offset;
+  Elf32_Addr entry;
 
   linux_size = grub_elf32_size (elf, &base_addr, &align);
   if (linux_size == 0)
@@ -160,9 +161,12 @@ grub_linux_load32 (grub_elf_t elf)
   /* Pad it; the kernel scribbles over memory beyond its load address.  */
   linux_size += 0x100000;
 
-  offset = elf->ehdr.ehdr32.e_entry - base_addr;
+  /* Linux's entry point incorrectly contains a virtual address.  */
+  entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK;
+
   /* Linux's incorrectly contains a virtual address.  */
   base_addr &= ~ELF32_LOADMASK;
+  offset = entry - base_addr;
 
   /* On some systems, firmware occupies the memory we're trying to use.
    * Happily, Linux can be loaded anywhere (it relocates itself).  Iterate
@@ -196,7 +200,8 @@ grub_linux_load64 (grub_elf_t elf)
   Elf64_Addr base_addr;
   grub_addr_t seg_addr;
   grub_uint64_t align;
-  int offset;
+  grub_uint64_t offset;
+  Elf64_Addr entry;
 
   linux_size = grub_elf64_size (elf, &base_addr, &align);
   if (linux_size == 0)
@@ -204,9 +209,10 @@ grub_linux_load64 (grub_elf_t elf)
   /* Pad it; the kernel scribbles over memory beyond its load address.  */
   linux_size += 0x100000;
 
-  offset = elf->ehdr.ehdr64.e_entry - base_addr;
-  /* Linux's incorrectly contains a virtual address.  */
   base_addr &= ~ELF64_LOADMASK;
+  entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK;
+  offset = entry - base_addr;
+  /* Linux's incorrectly contains a virtual address.  */
 
   /* On some systems, firmware occupies the memory we're trying to use.
    * Happily, Linux can be loaded anywhere (it relocates itself).  Iterate