]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-mkimagexx.c (locate_sections): Reject mislinked images.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 2 Nov 2013 18:16:36 +0000 (19:16 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 2 Nov 2013 18:16:36 +0000 (19:16 +0100)
ChangeLog
util/grub-mkimagexx.c

index 8f8504d9da31ce7457811b4bf069770b559f708d..243e4e9ccd60be293d1b76bbfaee5ac092478871 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 387461311b6d8f6258cc923fc7aaa76fb25f1d80..00d1efff16f14c08cae69fcb6eadb5eaf8b5bfac 100644 (file)
@@ -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);