Support grub-emu on x32 (ILP32 but with x86-64 instruction set)

* configure.ac: Remove -m64 from checks for -mcmodel=large and
-mno-red-zone.  These are always either unnecessary (x86_64-emu) or
already in TARGET_CFLAGS at this point, and they produce incorrect
results when building for x32.
* grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Cast
pointers to Elf64_Xword via grub_addr_t, in order to work on x32.
* include/grub/x86_64/types.h (GRUB_TARGET_SIZEOF_VOID_P,
GRUB_TARGET_SIZEOF_LONG): Define to 4 on x32.
This commit is contained in:
Colin Watson 2014-09-07 23:04:35 +01:00
parent 4d94b2db58
commit 2a5a532c00
4 changed files with 22 additions and 5 deletions

View file

@ -73,7 +73,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
{
grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
(Elf64_Xword) seg->addr - rel->r_offset;
(Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset;
if (value != (grub_int32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
@ -83,7 +83,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
case R_X86_64_PC64:
{
*addr64 += rel->r_addend + sym->st_value -
(Elf64_Xword) seg->addr - rel->r_offset;
(Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset;
}
break;