From 8de23b4ac778e37a693c247c861f85fb3ee5f56e Mon Sep 17 00:00:00 2001
From: Ross Lagerwall <ross.lagerwall@citrix.com>
Date: Tue, 3 Nov 2015 14:44:49 +0000
Subject: [PATCH] Add 64 bytes of padding to xsplice_patch_funcs structure and
 shrink the size

This gives the hypervisor scratch space for undo buffers and possibly
other uses.

Also we change the size to be uint32_t instead of unsigned long.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 common.h             | 8 ++++----
 create-diff-object.c | 5 +++--
 lookup.h             | 2 +-
 prelink.c            | 2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/common.h b/common.h
index d78275c..c16eb38 100644
--- a/common.h
+++ b/common.h
@@ -117,12 +117,12 @@ struct xsplice_elf {
 #define PATCH_INSN_SIZE 5
 
 struct xsplice_patch_func {
+	char *name;
 	unsigned long new_addr;
-	unsigned long new_size;
 	unsigned long old_addr;
-	unsigned long old_size;
-	char *name;
-	unsigned char undo[8];
+	uint32_t new_size;
+	uint32_t old_size;
+	unsigned char pad[32];
 };
 
 struct special_section {
diff --git a/create-diff-object.c b/create-diff-object.c
index 15c4115..be7e90a 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1497,7 +1497,7 @@ static void xsplice_create_patches_sections(struct xsplice_elf *kelf,
 					ERROR("lookup_global_symbol %s",
 					      sym->name);
 			}
-			log_debug("lookup for %s @ 0x%016lx len %lu\n",
+			log_debug("lookup for %s @ 0x%016lx len %u\n",
 			          sym->name, result.value, result.size);
 
 			if (result.size < PATCH_INSN_SIZE)
@@ -1508,7 +1508,8 @@ static void xsplice_create_patches_sections(struct xsplice_elf *kelf,
 			funcs[index].old_size = result.size;
 			funcs[index].new_addr = 0;
 			funcs[index].new_size = sym->sym.st_size;
-			memset(funcs[index].undo, 0, sizeof funcs[index].undo);
+			funcs[index].name = NULL;
+			memset(funcs[index].pad, 0, sizeof funcs[index].pad);
 
 			/*
 			 * Add a relocation that will populate
diff --git a/lookup.h b/lookup.h
index cbb3dae..73fff52 100644
--- a/lookup.h
+++ b/lookup.h
@@ -5,7 +5,7 @@ struct lookup_table;
 
 struct lookup_result {
 	unsigned long value;
-	unsigned long size;
+	uint16_t size;
 };
 
 struct lookup_table *lookup_open(char *path);
diff --git a/prelink.c b/prelink.c
index f922871..9e6234c 100644
--- a/prelink.c
+++ b/prelink.c
@@ -73,7 +73,7 @@ void xsplice_resolve_symbols(struct xsplice_elf *kelf,
 				ERROR("lookup_global_symbol %s",
 				      sym->name);
 		}
-		log_debug("lookup for %s @ 0x%016lx len %lu\n",
+		log_debug("lookup for %s @ 0x%016lx len %u\n",
 			  sym->name, result.value, result.size);
 		sym->sym.st_value = result.value;
 		sym->sym.st_shndx = SHN_ABS;
-- 
2.4.3

