summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2017-12-19 01:04:35 +0100
committerRobert Swiecki <robert@swiecki.net>2017-12-19 01:04:35 +0100
commitb7071738c37446c5f9f533d7e4664869770c38a3 (patch)
tree3715642f691998d700c385f8effe78abf71b0bfe
parentad95f5c98130b3f100970a3e55ff8e00bf670f54 (diff)
downloadhonggfuzz-b7071738c37446c5f9f533d7e4664869770c38a3.tar.gz
Makefile: support _HF_USE_RET_ADDR_1
-rw-r--r--Makefile4
-rw-r--r--libhfuzz/memorycmp.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 0b0dd499..d5b32b45 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,10 @@ COMMON_SRCS := $(sort $(wildcard *.c))
CFLAGS ?= -O3
LDFLAGS ?=
LIBS_CFLAGS ?= -fPIC -fno-stack-protector -fno-builtin -D__NO_STRING_INLINES -D__NO_INLINE__
+HFUZZ_USE_RET_1 ?= false
+ifeq ($(HFUZZ_USE_RET_1),true)
+ LIBS_CFLAGS += -D_HF_USE_RET_ADDR_1 -Wno-error=frame-address
+endif
OS ?= $(shell uname -s)
MARCH ?= $(shell uname -m)
diff --git a/libhfuzz/memorycmp.c b/libhfuzz/memorycmp.c
index e3c8c58b..f0599ac7 100644
--- a/libhfuzz/memorycmp.c
+++ b/libhfuzz/memorycmp.c
@@ -6,9 +6,9 @@
int hfuzz_module_memorycmp = 0;
-#if 0 /* Might be useful with defined(__x86_64__) */
+#if defined(_HF_USE_RET_ADDR_1) /* Use mix of two previous addresses */
#define RET_CALL_CHAIN \
- ((uintptr_t)__builtin_return_address(0) & 0xFFF) | \
+ ((uintptr_t)__builtin_return_address(0)) ^ \
((uintptr_t)__builtin_return_address(1) << 12)
#else
#define RET_CALL_CHAIN (uintptr_t) __builtin_return_address(0)