Remove check_thunks reliance on Tier0.

This commit is contained in:
Asher Baker 2015-05-07 21:56:31 +01:00
parent 16b7c576d4
commit 97605a500c

View File

@ -4,6 +4,8 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include <dlfcn.h> #include <dlfcn.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define REG_EAX 0 #define REG_EAX 0
#define REG_ECX 1 #define REG_ECX 1
@ -13,8 +15,6 @@
#define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32> #define IA32_MOV_REG_IMM 0xB8 // encoding is +r <imm32>
#endif #endif
extern void Msg( const char *, ... );
/** /**
* Checks if a call to a fpic thunk has just been written into dest. * Checks if a call to a fpic thunk has just been written into dest.
* If found replaces it with a direct mov that sets the required register to the value of pc. * If found replaces it with a direct mov that sets the required register to the value of pc.
@ -25,9 +25,7 @@ extern void Msg( const char *, ... );
*/ */
void check_thunks(unsigned char *dest, unsigned char *pc) void check_thunks(unsigned char *dest, unsigned char *pc)
{ {
#if defined WIN32 #ifndef WIN32
return;
#else
/* Step write address back 4 to the start of the function address */ /* Step write address back 4 to the start of the function address */
unsigned char *writeaddr = dest - 4; unsigned char *writeaddr = dest - 4;
unsigned char *calloffset = *(unsigned char **)writeaddr; unsigned char *calloffset = *(unsigned char **)writeaddr;
@ -64,7 +62,10 @@ void check_thunks(unsigned char *dest, unsigned char *pc)
} }
default: default:
{ {
Msg("Unknown thunk: %c\n", *(calladdr+1)); printf("Unknown thunk: %c\n", *(calladdr+1));
#ifndef NDEBUG
abort();
#endif
break; break;
} }
} }
@ -81,8 +82,6 @@ void check_thunks(unsigned char *dest, unsigned char *pc)
*(void **)writeaddr = (void *)pc; *(void **)writeaddr = (void *)pc;
writeaddr += 4; writeaddr += 4;
} }
return;
#endif #endif
} }