]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fixes for backwards relocator
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 26 Nov 2009 21:51:00 +0000 (22:51 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 26 Nov 2009 21:51:00 +0000 (22:51 +0100)
lib/i386/relocator_asm.S
lib/relocator.c

index bd25143e8496a74fac137d23926efa3c79ea2404..c1be85c2b1a7084089c9dbe3a6239df1052ec092 100644 (file)
 #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
index 31695ff62534afee8036963e1b883c938a011a2d..176379eb775cd771043755bb8df2785d5261d368 100644 (file)
@@ -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",