From e89174c3f12141a39374c880da13cc41b694b3bc Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 4 Sep 2015 07:56:35 -0400 Subject: [PATCH 1/2] Fix build of regress/ --- regress/Makefile | 5 ++++- regress/block_test.c | 3 ++- samples/Makefile | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/regress/Makefile b/regress/Makefile index 14d5c383..09214579 100644 --- a/regress/Makefile +++ b/regress/Makefile @@ -1,5 +1,5 @@ CFLAGS += -I../include -LDFLAGS = -L.. -lunicorn +LDFLAGS += ../libunicorn.a $(shell pkg-config --libs glib-2.0) -lpthread -lm TESTS = map_crash map_write TESTS += sigill sigill2 @@ -16,4 +16,7 @@ all: $(TESTS) clean: rm -f $(TESTS) +%: %.c + $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ + .PHONY: all clean diff --git a/regress/block_test.c b/regress/block_test.c index 7aaf1b93..4cc2a826 100644 --- a/regress/block_test.c +++ b/regress/block_test.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -13,7 +14,7 @@ static int count = 1; // @size: size of machine instruction being executed // @user_data: user data passed to tracing APIs. void cb_hookblock(ucengine *uc, uint64_t address, uint32_t size, void *user_data) { - fprintf(stderr, "# >>> Tracing basic block at 0x%llx, block size = 0x%x\n", address, size); + fprintf(stderr, "# >>> Tracing basic block at 0x%"PRIx64", block size = 0x%x\n", address, size); if (address != 0x1000000 && address != 0x1000200) { fprintf(stderr, "not ok %d - address != 0x1000000 && address != 0x1000200\n", count++); _exit(1); diff --git a/samples/Makefile b/samples/Makefile index 1ebb891f..aad79ad2 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -7,7 +7,7 @@ LIBNAME = unicorn # Find GLIB ifndef GLIB -GLIB = `pkg-config --libs glib-2.0` +GLIB = $(shell pkg-config --libs glib-2.0) endif UNICORN_DEP_LIBS_STATIC += -lpthread -lm $(GLIB) From caad81e2da6147e72401d350318442a22f53fdcc Mon Sep 17 00:00:00 2001 From: fabs Date: Fri, 4 Sep 2015 17:56:29 +0200 Subject: [PATCH 2/2] Add UNICORN_QEMU_FLAGS Fixes #107 --- COMPILE.TXT | 3 ++- Makefile | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/COMPILE.TXT b/COMPILE.TXT index fa2b1d7c..53d6885f 100644 --- a/COMPILE.TXT +++ b/COMPILE.TXT @@ -43,11 +43,12 @@ Unicorn requires few dependent packages as followings The other way of customize Unicorn without having to edit config.mk is to pass the desired options on the commandline to ./make.sh. Currently, - Unicorn supports 3 options, as followings. + Unicorn supports 4 options, as followings. - UNICORN_ARCHS: specify list of architectures to compiled in. - UNICORN_STATIC: build static library. - UNICORN_SHARED: build dynamic (shared) library. + - UNICORN_QEMU_FLAGS: specify extra flags for qemu's configure script To avoid editing config.mk for these customization, we can pass their values to make.sh, as followings. diff --git a/Makefile b/Makefile index d62eec00..148baa73 100644 --- a/Makefile +++ b/Makefile @@ -204,11 +204,11 @@ config: qemu/config-host.h-timestamp: ifeq ($(UNICORN_DEBUG),yes) cd qemu && \ - ./configure --extra-cflags="$(UNICORN_CFLAGS)" --target-list="$(UNICORN_TARGETS)" + ./configure --extra-cflags="$(UNICORN_CFLAGS)" --target-list="$(UNICORN_TARGETS)" ${UNICORN_QEMU_FLAGS} printf "$(UNICORN_ARCHS)" > config.log else cd qemu && \ - ./configure --disable-debug-info --extra-cflags="$(UNICORN_CFLAGS)" --target-list="$(UNICORN_TARGETS)" + ./configure --disable-debug-info --extra-cflags="$(UNICORN_CFLAGS)" --target-list="$(UNICORN_TARGETS)" ${UNICORN_QEMU_FLAGS} printf "$(UNICORN_ARCHS)" > config.log endif