grub_size_t grub_relocator_align = 1;
grub_size_t grub_relocator_forward_size;
grub_size_t grub_relocator_backward_size;
-grub_size_t grub_relocator_jumper_size = 10;
+#ifdef __x86_64__
+grub_size_t grub_relocator_jumper_size = 12;
+#else
+grub_size_t grub_relocator_jumper_size = 7;
+#endif
void
grub_cpu_relocator_init (void)
{
grub_uint8_t *ptr;
ptr = rels;
- /* movl $addr, %eax (for relocator) */
+#ifdef __x86_64__
+ /* movq imm64, %rax (for relocator) */
+ *(grub_uint8_t *) ptr = 0x48;
+ ptr++;
+ *(grub_uint8_t *) ptr = 0xb8;
+ ptr++;
+ *(grub_uint64_t *) ptr = addr;
+ ptr += sizeof (grub_uint64_t);
+#else
+ /* movl imm32, %eax (for relocator) */
*(grub_uint8_t *) ptr = 0xb8;
ptr++;
*(grub_uint32_t *) ptr = addr;
- ptr += 4;
- /* jmp $addr */
- *(grub_uint8_t *) ptr = 0xe9;
+ ptr += sizeof (grub_uint32_t);
+#endif
+ /* jmp $eax/$rax */
+ *(grub_uint8_t *) ptr = 0xff;
+ ptr++;
+ *(grub_uint8_t *) ptr = 0xe0;
ptr++;
- *(grub_uint32_t *) ptr = addr - (grub_uint32_t) (ptr + 4);
- ptr += 4;
}
void
ret->postchunks = ~(grub_addr_t) 0;
ret->relocators_size = grub_relocator_jumper_size;
- grub_dprintf ("relocator", "relocators_size=%d\n", ret->relocators_size);
+ grub_dprintf ("relocator", "relocators_size=%ld\n", ret->relocators_size);
return ret;
}
hb = h;
hbp = hp;
*best_addr = addr;
- grub_dprintf ("relocator", "picked %p/%x\n", hb, addr);
+ grub_dprintf ("relocator", "picked %p/%lx\n", hb, addr);
}
}
else
hb = h;
hbp = hp;
*best_addr = addr;
- grub_dprintf ("relocator", "picked %p/%x\n", hb, addr);
+ grub_dprintf ("relocator", "picked %p/%lx\n", hb, addr);
}
}
}
hb = get_best_header (rel, start, end, align, size, rb, &hbp, &best_addr,
from_low_priv, collisioncheck);
- grub_dprintf ("relocator", "best header %p/%x\n", hb, best_addr);
+ grub_dprintf ("relocator", "best header %p/%lx\n", hb, best_addr);
if (!hb)
{
rel->highestnonpostaddr = start + size;
}
- grub_dprintf ("relocator", "relocators_size=%d\n", rel->relocators_size);
+ grub_dprintf ("relocator", "relocators_size=%ld\n", rel->relocators_size);
if (start < target)
rel->relocators_size += grub_relocator_backward_size;
if (start > target)
rel->relocators_size += grub_relocator_forward_size;
- grub_dprintf ("relocator", "relocators_size=%d\n", rel->relocators_size);
+ grub_dprintf ("relocator", "relocators_size=%ld\n", rel->relocators_size);
chunk->src = start;
chunk->target = target;
}
adjust_limits (rel, &min_addr2, &max_addr2, min_addr, max_addr);
- grub_dprintf ("relocator", "Adjusted limits from %x-%x to %x-%x\n",
+ grub_dprintf ("relocator", "Adjusted limits from %lx-%lx to %lx-%lx\n",
min_addr, max_addr, min_addr2, max_addr2);
do
grub_addr_t rels;
grub_addr_t rels0;
- grub_dprintf ("relocator", "Preparing relocs (size=%d)\n",
+ grub_dprintf ("relocator", "Preparing relocs (size=%ld)\n",
rel->relocators_size);
if (!malloc_in_range (rel, 0, ~(grub_addr_t)0 - rel->relocators_size + 1,