]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
First handling of ia64-efi in grub-mkimage
authorphcoder <phcoder@debian>
Mon, 3 Jan 2011 12:46:36 +0000 (13:46 +0100)
committerphcoder <phcoder@debian>
Mon, 3 Jan 2011 12:46:36 +0000 (13:46 +0100)
grub-core/Makefile.core.def
include/grub/efi/pe32.h
util/grub-mkimage.c
util/grub-mkimagexx.c

index 4581b79cfdc51523d224dbc47ac000f4572f3b30..c21c387633484644168fca621caf5940fd091f36 100644 (file)
@@ -24,8 +24,8 @@ kernel = {
   x86_64_efi_stripflags    = '--strip-unneeded -K start -R .note -R .comment';
 
   ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput';
-  ia64_efi_ldflags = '-melf_64';
-  ia64_efi_stripflags = '-R .note -R .comment -X';
+  ia64_efi_ldflags = '-Wl,-r,-d';
+  ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment';
 
   i386_pc_ldflags          = '$(TARGET_IMG_LDFLAGS)';
   i386_pc_ldflags          = '$(TARGET_IMG_BASE_LDOPT),0x8200';
index 81a1a579767c3a0ffe6122ada012a44b76e4ac7c..c3efa9b3d906c64ec603f6d420b77a9bbc30ced4 100644 (file)
@@ -64,6 +64,7 @@ struct grub_pe32_coff_header
 };
 
 #define GRUB_PE32_MACHINE_I386         0x14c
+#define GRUB_PE32_MACHINE_IA64         0x200
 #define GRUB_PE32_MACHINE_X86_64       0x8664
 
 #define GRUB_PE32_RELOCS_STRIPPED              0x0001
index 53e867602c7e5da377a8c582623100aaf4d712b8..507a7a80d6f5e2177cffa9b95a0cdd3cbe0029bf 100644 (file)
@@ -86,6 +86,7 @@ struct image_target_desc
   grub_uint64_t link_addr;
   unsigned mod_gap, mod_align;
   grub_compression_t default_compression;
+  grub_uint16_t pe_target;
 };
 
 struct image_target_desc image_targets[] =
@@ -191,6 +192,8 @@ struct image_target_desc image_targets[] =
                                GRUB_PE32_SECTION_ALIGNMENT),
       .install_dos_part = TARGET_NO_FIELD,
       .install_bsd_part = TARGET_NO_FIELD,
+      .pe_target = GRUB_PE32_MACHINE_I386,
+      .elf_target = EM_386,
     },
     {
       .name = "i386-ieee1275",
@@ -253,6 +256,8 @@ struct image_target_desc image_targets[] =
                                GRUB_PE32_SECTION_ALIGNMENT),
       .install_dos_part = TARGET_NO_FIELD,
       .install_bsd_part = TARGET_NO_FIELD,
+      .pe_target = GRUB_PE32_MACHINE_X86_64,
+      .elf_target = EM_X86_64,
     },
     {
       .name = "mipsel-yeeloong-flash",
@@ -354,6 +359,30 @@ struct image_target_desc image_targets[] =
       .install_bsd_part = TARGET_NO_FIELD,
       .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
     },
+    {
+      .name = "ia64-efi",
+      .voidp_sizeof = 8,
+      .bigendian = 0, 
+      .id = IMAGE_EFI, 
+      .flags = PLATFORM_FLAGS_NONE,
+      .prefix = GRUB_KERNEL_IA64_EFI_PREFIX,
+      .prefix_end = GRUB_KERNEL_IA64_EFI_PREFIX_END,
+      .raw_size = 0,
+      .total_module_size = TARGET_NO_FIELD,
+      .kernel_image_size = TARGET_NO_FIELD,
+      .compressed_size = TARGET_NO_FIELD,
+      .section_align = GRUB_PE32_SECTION_ALIGNMENT,
+      .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+                               + GRUB_PE32_SIGNATURE_SIZE
+                               + sizeof (struct grub_pe32_coff_header)
+                               + sizeof (struct grub_pe64_optional_header)
+                               + 4 * sizeof (struct grub_pe32_section_table),
+                               GRUB_PE32_SECTION_ALIGNMENT),
+      .install_dos_part = TARGET_NO_FIELD,
+      .install_bsd_part = TARGET_NO_FIELD,
+      .pe_target = GRUB_PE32_MACHINE_IA64,
+      .elf_target = EM_IA_64,
+    },
   };
 
 #define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
@@ -927,10 +956,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
        /* The COFF file header.  */
        c = (struct grub_pe32_coff_header *) (header + GRUB_PE32_MSDOS_STUB_SIZE
                                              + GRUB_PE32_SIGNATURE_SIZE);
-       if (image_target->voidp_sizeof == 4)
-         c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
-       else
-         c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_X86_64);
+       c->machine = grub_host_to_target16 (image_target->pe_target);
 
        c->num_sections = grub_host_to_target16 (4);
        c->time = grub_host_to_target32 (time (0));
index ce51f2fbc0a518edbb1a77d9513427baa49451b4..20cbacf15d7b251edb6e2c55c139b540d3819db3 100644 (file)
@@ -101,9 +101,9 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
       else if (index >= num_sections)
        grub_util_error ("section %d does not exist", index);
 
-      sym->st_value = (grub_target_to_host32 (sym->st_value)
+      sym->st_value = (grub_target_to_host (sym->st_value)
                       + section_addresses[index]);
-      grub_util_info ("locating %s at 0x%x", name, sym->st_value);
+      grub_util_info ("locating %s at 0x%x", name, sym->st_value, section_addresses[index]);
 
       if (! start_address)
        if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0)
@@ -200,7 +200,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
             addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
              r->r_addend : 0;
 
-           if (image_target->voidp_sizeof == 4)
+          switch (image_target->elf_target)
+            {
+            case EM_386:
              switch (ELF_R_TYPE (info))
                {
                case R_386_NONE:
@@ -224,11 +226,12 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
                                  *target, offset);
                  break;
                default:
-                 grub_util_error ("unknown relocation type %d",
+                 grub_util_error ("unknown relocation type 0x%x",
                                   ELF_R_TYPE (info));
                  break;
                }
-           else
+             break;
+            case EM_X86_64:
              switch (ELF_R_TYPE (info))
                {
 
@@ -270,6 +273,20 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
                                   ELF_R_TYPE (info));
                  break;
                }
+             break;
+            case EM_IA_64:
+             switch (ELF_R_TYPE (info))
+               {
+               default:
+                 grub_util_error ("unknown relocation type 0x%x",
+                                  ELF_R_TYPE (info));
+                 break;
+               }
+              break;
+            default:
+              grub_util_error ("unknown architecture type %d",
+                               image_target->elf_target);
+            }
          }
       }
 }
@@ -417,8 +434,9 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
            info = grub_le_to_cpu32 (r->r_info);
 
            /* Necessary to relocate only absolute addresses.  */
-           if (image_target->voidp_sizeof == 4)
+           switch (image_target->elf_target)
              {
+             case EM_386:
                if (ELF_R_TYPE (info) == R_386_32)
                  {
                    Elf_Addr addr;
@@ -431,9 +449,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
                                                  addr, 0, current_address,
                                                  image_target);
                  }
-             }
-           else
-             {
+               break;
+             case EM_X86_64:
                if ((ELF_R_TYPE (info) == R_X86_64_32) ||
                    (ELF_R_TYPE (info) == R_X86_64_32S))
                  {
@@ -452,6 +469,9 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
                                                  0, current_address,
                                                  image_target);
                  }
+               break;
+             default:
+               grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
              }
          }
       }