First handling of ia64-efi in grub-mkimage
This commit is contained in:
parent
c18271ed00
commit
bea3358389
4 changed files with 62 additions and 15 deletions
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue