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[] =
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",
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",
.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)))
/* 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));
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)
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:
*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))
{
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);
+ }
}
}
}
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;
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))
{
0, current_address,
image_target);
}
+ break;
+ default:
+ grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
}
}
}