From 67cd4e63822685baab293ab78267fefa9f7ace3d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 19 Sep 2020 11:20:59 +0000 Subject: [PATCH] NetBSD client build support. vm code needs this particular flag due to Pax protection as well. --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++----- code/qcommon/vm_x86.c | 6 +++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 816f253d..32e2478a 100644 --- a/Makefile +++ b/Makefile @@ -843,19 +843,53 @@ else # ifeq openbsd ifeq ($(PLATFORM),netbsd) - LIBS=-lm + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON + + CLIENT_CFLAGS += $(SDL_CFLAGS) + + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + + ifeq ($(ARCH),x86_64) + OPTIMIZEVM = -O3 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + HAVE_VM_COMPILED = true + else + ifeq ($(ARCH),x86) + OPTIMIZEVM = -O3 -march=i586 + OPTIMIZE = $(OPTIMIZEVM) -ffast-math + HAVE_VM_COMPILED=true + endif + endif + + ifeq ($(USE_CURL),1) + CLIENT_CFLAGS += $(CURL_CFLAGS) + USE_CURL_DLOPEN=0 + endif + SHLIBEXT=so SHLIBCFLAGS=-fPIC SHLIBLDFLAGS=-shared $(LDFLAGS) THREAD_LIBS=-lpthread + LIBS=-lm - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes + CLIENT_LIBS = - ifeq ($(ARCH),x86) - HAVE_VM_COMPILED=true + CLIENT_LIBS += $(SDL_LIBS) + RENDERER_LIBS = $(SDL_LIBS) + + ifeq ($(USE_OPENAL),1) + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS) + endif endif - BUILD_CLIENT = 0 + ifeq ($(USE_CURL),1) + ifneq ($(USE_CURL_DLOPEN),1) + CLIENT_LIBS += $(CURL_LIBS) + endif + endif else # ifeq netbsd ############################################################################# diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c index 6bf349f2..e36558eb 100644 --- a/code/qcommon/vm_x86.c +++ b/code/qcommon/vm_x86.c @@ -1648,7 +1648,11 @@ void VM_Compile(vm_t *vm, vmHeader_t *header) // copy to an exact sized buffer with the appropriate permission bits vm->codeLength = compiledOfs; #ifdef VM_X86_MMAP - vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); + int prot_flags = PROT_WRITE; +#ifdef __NetBSD__ + prot_flags |= PROT_MPROTECT(PROT_READ|PROT_EXEC); +#endif + vm->codeBase = mmap(NULL, compiledOfs, prot_flags, MAP_SHARED|MAP_ANONYMOUS, -1, 0); if(vm->codeBase == MAP_FAILED) Com_Error(ERR_FATAL, "VM_CompileX86: can't mmap memory"); #elif _WIN32