diff --git a/Makefile b/Makefile index 09e0b200..b71de9ed 100644 --- a/Makefile +++ b/Makefile @@ -211,12 +211,28 @@ qemu/config-host.h-timestamp: unicorn: $(LIBRARY) $(ARCHIVE) $(LIBRARY): qemu/config-host.h-timestamp uc.o list.o +ifeq ($(UNICORN_SHARED),yes) +ifeq ($(V),0) + $(call log,GEN,$(LIBRARY)) + @$(CC) $(CFLAGS) -shared $(UC_TARGET_OBJ) uc.o list.o -o $(LIBRARY) $($(LIBNAME)_LDFLAGS) + @-ln -sf $(LIBRARY) $(LIBRARY_SYMLINK) +else $(CC) $(CFLAGS) -shared $(UC_TARGET_OBJ) uc.o list.o -o $(LIBRARY) $($(LIBNAME)_LDFLAGS) -ln -sf $(LIBRARY) $(LIBRARY_SYMLINK) +endif +endif $(ARCHIVE): qemu/config-host.h-timestamp uc.o list.o +ifeq ($(UNICORN_STATIC),yes) +ifeq ($(V),0) + $(call log,GEN,$(ARCHIVE)) + @$(AR) q $(ARCHIVE) $(UC_TARGET_OBJ) uc.o list.o + @$(RANLIB) $(ARCHIVE) +else $(AR) q $(ARCHIVE) $(UC_TARGET_OBJ) uc.o list.o $(RANLIB) $(ARCHIVE) +endif +endif $(PKGCFGF): $(generate-pkgcfg) diff --git a/bindings/python/sample_arm.py b/bindings/python/sample_arm.py index 13292320..402ba57a 100755 --- a/bindings/python/sample_arm.py +++ b/bindings/python/sample_arm.py @@ -45,7 +45,7 @@ def test_arm(): # tracing all basic blocks with customized callback mu.hook_add(UC_HOOK_BLOCK, hook_block) - # tracing all instructions with customized callback + # tracing one instruction at ADDRESS with customized callback mu.hook_add(UC_HOOK_CODE, hook_code, begin=ADDRESS, end=ADDRESS) # emulate machine code in infinite time diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb index 1543010d..81068a6e 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb @@ -4,6 +4,11 @@ module Unicorn UC_API_MAJOR = 1 UC_API_MINOR = 0 + UC_VERSION_MAJOR = 1 + + UC_VERSION_MINOR = 0 + + UC_VERSION_EXTRA = 0 UC_SECOND_SCALE = 1000000 UC_MILISECOND_SCALE = 1000 UC_ARCH_ARM = 1 diff --git a/samples/Makefile b/samples/Makefile index 830cd68b..1ad37aa1 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -10,11 +10,13 @@ ifndef GLIB GLIB = $(shell pkg-config --libs glib-2.0) endif +BIN_EXT = + # Verbose output? V ?= 0 CFLAGS += -Wall -Werror -I../include -LDFLAGS += -L.. +LDFLAGS += -L.. -lunicorn LDLIBS += -lpthread -lunicorn -lm $(GLIB) ifneq ($(CROSS),) @@ -32,9 +34,11 @@ endif ifneq ($(filter CYGWIN%,$(UNAME_S)),) CFLAGS := $(CFLAGS:-fPIC=) LDLIBS += -lssp +BIN_EXT = .exe # mingw? else ifneq ($(filter MINGW%,$(UNAME_S)),) CFLAGS := $(CFLAGS:-fPIC=) +BIN_EXT = .exe endif .PHONY: all clean @@ -69,9 +73,58 @@ ifneq (,$(findstring m68k,$(UNICORN_ARCHS))) SOURCES += sample_m68k.c endif -BINS = $(SOURCES:.c=) +BINS = $(SOURCES:.c=$(BIN_EXT)) +OBJS = $(SOURCES:.c=.o) all: $(BINS) +$(BINS): $(OBJS) + clean: rm -rf *.o $(BINS) + +%$(BIN_EXT): %.o + @mkdir -p $(@D) +ifeq ($(V),0) +ifeq ($(UNICORN_SHARED),yes) + $(call log,LINK,$(notdir $@)) + @$(link-dynamic) +endif +ifeq ($(UNICORN_STATIC),yes) +ifneq ($(filter MINGW%,$(UNAME_S)),) + $(call log,LINK,$(notdir $(call staticname,$@))) + @$(link-static) +endif +endif +else +ifeq ($(UNICORN_SHARED),yes) + $(link-dynamic) +endif +ifeq ($(UNICORN_STATIC),yes) +ifneq ($(filter MINGW%,$(UNAME_S)),) + $(link-static) +endif +endif +endif + +%.o: %.c + @mkdir -p $(@D) +ifeq ($(V),0) + $(call log,CC,$(@:%=%)) + @$(compile) +else + $(compile) +endif + + +define link-dynamic + $(CC) $< $(LDFLAGS) -o $@ +endef + + +define link-static + $(CC) $< $(ARCHIVE) $(LDFLAGS_STATIC) -o $(call staticname,$@) +endef + + +staticname = $(subst $(BIN_EXT),,$(1)).static$(BIN_EXT)