Fixed bug where JIT did not work on linux (memory alignment issues)
This commit is contained in:
parent
31436e3ecf
commit
eaf102d78f
@ -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
|
||||
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include "osdefs.h"
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#include <sclinux.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#if !defined AMX_NODYNALOAD
|
||||
#include <dlfcn.h>
|
||||
#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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user