* 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.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-01-11 23:01:07 +01:00
parent 86205c94c3
commit 9da068a5dc
2 changed files with 17 additions and 5 deletions

View File

@ -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

View 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