Correct build settings for xnu kext. Changed calloc name to avoid potential conflicts

test2
Pb 9 years ago
parent fce4977014
commit 2769c772ce
  1. 6
      Makefile
  2. 4
      cs.c
  3. 2
      make.sh

@ -45,6 +45,12 @@ endif
ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes)
CFLAGS += -DCAPSTONE_HAS_OSXKERNEL
SDKROOT ?= $(shell xcodebuild -version -sdk macosx Path)
CFLAGS += -mmacosx-version-min=10.5 \
-isysroot$(SDKROOT) \
-I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/Headers \
-mkernel \
-fno-builtin
endif
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))

@ -94,12 +94,12 @@ extern void* kern_os_malloc(size_t size);
extern void kern_os_free(void* addr);
extern void* kern_os_realloc(void* addr, size_t nsize);
static void* kern_os_calloc(size_t num, size_t size) {
static void* cs_kern_os_calloc(size_t num, size_t size) {
return kern_os_malloc(num * size); // malloc bzeroes the buffer
}
cs_malloc_t cs_mem_malloc = kern_os_malloc;
cs_calloc_t cs_mem_calloc = kern_os_calloc;
cs_calloc_t cs_mem_calloc = cs_kern_os_calloc;
cs_realloc_t cs_mem_realloc = kern_os_realloc;
cs_free_t cs_mem_free = kern_os_free;
cs_vsnprintf_t cs_vsnprintf = vsnprintf;

@ -143,7 +143,7 @@ case "$TARGET" in
"ios_armv7" ) build_iOS armv7 $*;;
"ios_armv7s" ) build_iOS armv7s $*;;
"ios_arm64" ) build_iOS arm64 $*;;
"osx-kernel" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_HAS_OSXKERNEL=yes build $*;;
"osx-kernel" ) CAPSTONE_USE_SYS_DYN_MEM=yes CAPSTONE_HAS_OSXKERNEL=yes CAPSTONE_ARCHS=x86 CAPSTONE_SHARED=no CAPSTONE_BUILD_CORE_ONLY=yes build $*;;
* )
echo "Usage: $0 ["`grep '^ "' $0 | cut -d '"' -f 2 | tr "\\n" "|"`"]"
exit 1;;

Loading…
Cancel
Save