diff --git a/amxmodx/Makefile b/amxmodx/Makefile index 7bb021ea..0882103d 100755 --- a/amxmodx/Makefile +++ b/amxmodx/Makefile @@ -17,7 +17,7 @@ OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \ CMenu.cpp util.cpp amx.cpp amxdbg.cpp -LINK = -lz JIT/amxexecn.o JIT/amxjitsn.o +LINK = -lz INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \ -I$(MM_ROOT) -Lzlib -I$(HLSDK)/common @@ -41,7 +41,8 @@ ifeq "$(AMD64)" "true" CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64 else BINARY = $(NAME)_i386.so - CFLAGS += -DPAWN_CELL_SIZE=32 + OBJECTS += JIT/amxexecn.o JIT/amxjitsn.o + CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32 OPT_FLAGS += -march=i686 endif diff --git a/amxmodx/amx.cpp b/amxmodx/amx.cpp index b7944c47..b7f69a73 100755 --- a/amxmodx/amx.cpp +++ b/amxmodx/amx.cpp @@ -49,6 +49,8 @@ #include "osdefs.h" #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ #include + #include + #include #if !defined AMX_NODYNALOAD #include #endif @@ -1034,9 +1036,13 @@ int AMXAPI amx_Init(AMX *amx,void *program) return !VirtualProtect(addr, len, p, &prev); } + #define ALIGN(addr) (addr) + #elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ /* Linux already has mprotect() */ + /* But wants the address aligned! */ + #define ALIGN(addr) (char *)(((long)addr + sysconf(_SC_PAGESIZE)-1) & ~(sysconf(_SC_PAGESIZE)-1)) #else @@ -1064,7 +1070,7 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code) */ assert(amx->sysreq_d==0); - if (mprotect(asm_runJIT, CODESIZE_JIT, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) + if (mprotect(ALIGN(asm_runJIT), CODESIZE_JIT, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) { return AMX_ERR_INIT_JIT; } diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 62697978..ac8107e9 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -392,7 +392,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64 { delete[] np; delete[] rt; - strcpy(error,"Failed to initialize plugin"); + strcpy(error,"Failed to initialize JIT'd plugin"); return (amx->error = AMX_ERR_INIT); }