* util/grub-mkimagexx.c (locate_sections): Reject mislinked images.
This commit is contained in:
parent
5cf9459c08
commit
a0c9d5c6d9
2 changed files with 19 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkimagexx.c (locate_sections): Reject mislinked images.
|
||||
|
||||
2013-11-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Use 0x8000 for address instead of 8000.
|
||||
|
|
|
@ -806,7 +806,8 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i
|
|||
into .text and .data, respectively. Return the array of section
|
||||
addresses. */
|
||||
static Elf_Addr *
|
||||
SUFFIX (locate_sections) (Elf_Shdr *sections, Elf_Half section_entsize,
|
||||
SUFFIX (locate_sections) (const char *kernel_path,
|
||||
Elf_Shdr *sections, Elf_Half section_entsize,
|
||||
Elf_Half num_sections, const char *strtab,
|
||||
size_t *exec_size, size_t *kernel_sz,
|
||||
size_t *all_align,
|
||||
|
@ -846,8 +847,17 @@ SUFFIX (locate_sections) (Elf_Shdr *sections, Elf_Half section_entsize,
|
|||
grub_util_info ("locating the section %s at 0x%llx",
|
||||
name, (unsigned long long) current_address);
|
||||
if (image_target->id != IMAGE_EFI)
|
||||
current_address = grub_host_to_target_addr (s->sh_addr)
|
||||
- image_target->link_addr;
|
||||
{
|
||||
current_address = grub_host_to_target_addr (s->sh_addr)
|
||||
- image_target->link_addr;
|
||||
if (grub_host_to_target_addr (s->sh_addr)
|
||||
!= image_target->link_addr)
|
||||
grub_util_error ("`%s' is miscompiled: it's start address is 0x%llx"
|
||||
" instead of 0x%llx: ld.gold bug?",
|
||||
kernel_path,
|
||||
(unsigned long long) grub_host_to_target_addr (s->sh_addr),
|
||||
(unsigned long long) image_target->link_addr);
|
||||
}
|
||||
section_addresses[i] = current_address;
|
||||
current_address += grub_host_to_target_addr (s->sh_size);
|
||||
}
|
||||
|
@ -935,7 +945,8 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
|
|||
+ grub_host_to_target16 (e->e_shstrndx) * section_entsize);
|
||||
strtab = (char *) e + grub_host_to_target_addr (s->sh_offset);
|
||||
|
||||
section_addresses = SUFFIX (locate_sections) (sections, section_entsize,
|
||||
section_addresses = SUFFIX (locate_sections) (kernel_path,
|
||||
sections, section_entsize,
|
||||
num_sections, strtab,
|
||||
exec_size, kernel_sz, align,
|
||||
image_target);
|
||||
|
|
Loading…
Reference in a new issue