diff --git a/lib/i386/relocator_asm.S b/lib/i386/relocator_asm.S index bd25143e8..c1be85c2b 100644 --- a/lib/i386/relocator_asm.S +++ b/lib/i386/relocator_asm.S @@ -27,13 +27,11 @@ #ifdef __x86_64__ #define RAX %rax #define RCX %rcx -#define RDX %rdx #define RDI %rdi #define RSI %rdi #else #define RAX %eax #define RCX %ecx -#define RDX %edx #define RDI %edi #define RSI %esi #endif @@ -97,7 +95,7 @@ RELOCATOR_VARIABLE(size) #ifdef BACKWARD add RCX, RSI - add RDX, RDI + add RCX, RDI #endif #ifndef BACKWARD diff --git a/lib/relocator.c b/lib/relocator.c index 31695ff62..176379eb7 100644 --- a/lib/relocator.c +++ b/lib/relocator.c @@ -20,6 +20,7 @@ + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) \ + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) \ + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)) +#define PRE_REGION_SIZE (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) void * PREFIX (alloc) (grub_size_t size) @@ -32,7 +33,7 @@ PREFIX (alloc) (grub_size_t size) *(grub_size_t *) playground = size; - return playground + RELOCATOR_SIZEOF (forward); + return playground + PRE_REGION_SIZE; } void * @@ -40,7 +41,7 @@ PREFIX (realloc) (void *relocator, grub_size_t size) { char *playground; - playground = (char *) relocator - RELOCATOR_SIZEOF (forward); + playground = (char *) relocator - PRE_REGION_SIZE; playground = grub_realloc (playground, size + MAX_OVERHEAD); if (!playground) @@ -48,14 +49,14 @@ PREFIX (realloc) (void *relocator, grub_size_t size) *(grub_size_t *) playground = size; - return playground + RELOCATOR_SIZEOF (forward); + return playground + PRE_REGION_SIZE; } void PREFIX(free) (void *relocator) { if (relocator) - grub_free ((char *) relocator - RELOCATOR_SIZEOF (forward)); + grub_free ((char *) relocator - PRE_REGION_SIZE); } grub_err_t @@ -65,7 +66,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest, grub_size_t size; char *playground; - playground = (char *) relocator - RELOCATOR_SIZEOF (forward); + playground = (char *) relocator - PRE_REGION_SIZE; size = *(grub_size_t *) playground; grub_dprintf ("relocator", @@ -94,7 +95,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest, if (UINT_TO_PTR (dest) >= relocator) { int overhead; - overhead = + overhead = dest - ALIGN_UP (dest - RELOCATOR_SIZEOF (backward) - RELOCATOR_ALIGN, RELOCATOR_ALIGN); grub_dprintf ("relocator",