NetBSD client build support.

vm code needs this particular flag due to Pax protection as well.
This commit is contained in:
David Carlier 2020-09-19 11:20:59 +00:00
parent a0b89d72d0
commit 67cd4e6382
2 changed files with 44 additions and 6 deletions

View file

@ -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
#############################################################################

View file

@ -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