From 0f6a2b22b20870b5e94c1939bdc334d5e9109f96 Mon Sep 17 00:00:00 2001
From: an7s <an7s@git.zephyr-software.com>
Date: Mon, 4 Jan 2016 20:25:18 +0000
Subject: [PATCH] 64-bit version

---
 datashadow/datashadow_callbacks.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/datashadow/datashadow_callbacks.c b/datashadow/datashadow_callbacks.c
index 41370fb..dd5c1b7 100644
--- a/datashadow/datashadow_callbacks.c
+++ b/datashadow/datashadow_callbacks.c
@@ -2,6 +2,7 @@
  * Function pointer shadowing
  */
 
+#include <stdlib.h>
 #ifdef STRATA
 #include "all.h"
 #include "../insn.h"
@@ -30,7 +31,7 @@ __attribute__ ((externally_visible)) __attribute((used)) void fptr_shadow_check_
 
 #define MAX_DIAGNOSTIC_SIZE 1024
 
-// put this in a include somewher
+/*
 typedef struct
 {
         int edi;
@@ -43,6 +44,30 @@ typedef struct
         int eax;
         int flags;
 } reg_values_t;
+*/
+
+/*  the registers are saved onto the stack in this order */
+typedef struct reg_values reg_values_t;
+struct reg_values
+{
+    size_t flags;
+    size_t r15;
+    size_t r14;
+    size_t r13;
+    size_t r12;
+    size_t r11;
+    size_t r10;
+    size_t r9;
+    size_t r8;
+    size_t rax;
+    size_t rbx;
+    size_t rcx;
+    size_t rdx;
+    size_t rsi;
+    size_t rdi;
+    size_t rbp;
+    size_t rsp;
+};
 
 #ifdef STRATA
 // leave this function so that the linker includes this file
@@ -64,7 +89,9 @@ static void getDiagnostics(char *p_diagnostic, int p_shadowIndex, void* p_shadow
 // add to multi-valued table
 void fptr_shadow_define_64(void *p_retAddress, reg_values_t *p_rv, void *p_instrumented, int p_shadowIndex, void *p_shadowValue) 
 {
+#ifdef STRATA
 	char msg[MAX_DIAGNOSTIC_SIZE];
+#endif
 
 	add_shadow_entry(p_shadowIndex, p_shadowValue);		
 
@@ -78,7 +105,9 @@ void fptr_shadow_define_64(void *p_retAddress, reg_values_t *p_rv, void *p_instr
 // check to make sure values match
 void fptr_shadow_check_64(void *p_retAddress, reg_values_t *p_rv, void *p_instrumented, int p_shadowIndex, void **p_shadow)
 {
+#ifdef STRATA
 	char msg[MAX_DIAGNOSTIC_SIZE];
+#endif
 	void *restored;
 	int count = 0;
 
-- 
GitLab