mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-10 17:21:33 +00:00
fix makefiles for uc2 c examples
This commit is contained in:
parent
3609912f41
commit
ac169c3087
@ -1 +1 @@
|
||||
Subproject commit cbe5e32752773945e0142fac9f1b7a0ccb5dcdff
|
||||
Subproject commit 6ca490c66b949db20d8c861ebc8fb2e6ca725ead
|
@ -4,29 +4,28 @@
|
||||
.POSIX:
|
||||
UNAME_S =$(shell uname -s)# GNU make
|
||||
UNAME_S:sh=uname -s # BSD make
|
||||
_UNIQ=_QINU_
|
||||
|
||||
LIBDIR = ../../unicornafl
|
||||
UNICORNAFL_LIB = ../../unicornafl/build
|
||||
UNICORN_LIB = ../../unicornafl/unicorn/build
|
||||
BIN_EXT =
|
||||
AR_EXT = a
|
||||
|
||||
# Verbose output?
|
||||
V ?= 0
|
||||
|
||||
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
||||
CFLAGS += -Wall -Werror -I../../unicornafl/unicorn/include -I../../unicornafl/include
|
||||
|
||||
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
||||
LDFLAGS += -L$(UNICORNAFL_LIB) -L$(UNICORN_LIB) -lpthread -lm -lunicornafl -lunicorn -lc++
|
||||
|
||||
_LRT = $(_UNIQ)$(UNAME_S:Linux=)
|
||||
__LRT = $(_LRT:$(_UNIQ)=-lrt)
|
||||
LRT = $(__LRT:$(_UNIQ)=)
|
||||
ifeq ($(UNAME), Linux)
|
||||
# do something Linux-y
|
||||
LRT = -lrt
|
||||
else
|
||||
LRT =
|
||||
endif
|
||||
|
||||
LDFLAGS += $(LRT)
|
||||
|
||||
_CC = $(_UNIQ)$(CROSS)
|
||||
__CC = $(_CC:$(_UNIQ)=$(CC))
|
||||
MYCC = $(__CC:$(_UNIQ)$(CROSS)=$(CROSS)gcc)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: harness
|
||||
@ -34,14 +33,20 @@ all: harness
|
||||
clean:
|
||||
rm -rf *.o harness harness-debug
|
||||
|
||||
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -O3 -c harness.c
|
||||
harness.o: harness.c ../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -O3 -c harness.c
|
||||
|
||||
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -g -c harness.c -o $@
|
||||
harness-debug.o: harness.c ../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -g -c harness.c -o $@
|
||||
|
||||
../../unicornafl/build/libunicornafl.a:
|
||||
cd ../.. && ./build_unicorn_support.sh
|
||||
|
||||
harness: harness.o
|
||||
${MYCC} -L${LIBDIR} harness.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
||||
${CC} harness.o ../../unicornafl/build/libunicornafl.a $(LDFLAGS) -o $@
|
||||
|
||||
debug: harness-debug.o
|
||||
${MYCC} -L${LIBDIR} harness.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
${CC} harness.o ../../unicornafl/build/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
|
||||
fuzz: harness
|
||||
DYLD_FALLBACK_LIBRARY_PATH="../../unicornafl/unicorn/build" LD_LIBRARY_PATH="../../unicornafl/unicorn/build" ../../../afl-fuzz -m none -i sample_inputs -o out -- ./harness @@
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <unicorn/unicorn.h>
|
||||
#include <unicornafl/unicornafl.h>
|
||||
|
||||
// Path to the file containing the binary to emulate
|
||||
#define BINARY_FILE ("persistent_target_x86_64")
|
||||
@ -141,7 +142,7 @@ static void mem_map_checked(uc_engine *uc, uint64_t addr, size_t size, uint32_t
|
||||
//printf("SIZE %llx, align: %llx\n", size, ALIGNMENT);
|
||||
uc_err err = uc_mem_map(uc, addr, size, mode);
|
||||
if (err != UC_ERR_OK) {
|
||||
printf("Error mapping %ld bytes at 0x%lx: %s (mode: %d)\n", size, addr, uc_strerror(err), mode);
|
||||
printf("Error mapping %ld bytes at 0x%llx: %s (mode: %d)\n", size, (unsigned long long) addr, uc_strerror(err), (int) mode);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -184,7 +185,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
// Map memory.
|
||||
mem_map_checked(uc, BASE_ADDRESS, len, UC_PROT_ALL);
|
||||
printf("Len: %lx\n", len);
|
||||
printf("Len: %lx\n", (unsigned long) len);
|
||||
fflush(stdout);
|
||||
|
||||
// write machine code to be emulated to memory
|
||||
|
@ -4,29 +4,28 @@
|
||||
.POSIX:
|
||||
UNAME_S =$(shell uname -s)# GNU make
|
||||
UNAME_S:sh=uname -s # BSD make
|
||||
_UNIQ=_QINU_
|
||||
|
||||
LIBDIR = ../../unicornafl
|
||||
UNICORNAFL_LIB = ../../unicornafl/build
|
||||
UNICORN_LIB = ../../unicornafl/unicorn/build
|
||||
BIN_EXT =
|
||||
AR_EXT = a
|
||||
|
||||
# Verbose output?
|
||||
V ?= 0
|
||||
|
||||
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
||||
CFLAGS += -Wall -Werror -I../../unicornafl/unicorn/include -I../../unicornafl/include
|
||||
|
||||
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
||||
LDFLAGS += -L$(UNICORNAFL_LIB) -L$(UNICORN_LIB) -lpthread -lm -lunicornafl -lunicorn -lc++
|
||||
|
||||
_LRT = $(_UNIQ)$(UNAME_S)
|
||||
__LRT = $(_LRT:$(_UNIQ)Linux=-lrt)
|
||||
LRT = $(__LRT:$(_UNIQ)$(UNAME_S)=)
|
||||
ifeq ($(UNAME), Linux)
|
||||
# do something Linux-y
|
||||
LRT = -lrt
|
||||
else
|
||||
LRT =
|
||||
endif
|
||||
|
||||
LDFLAGS += $(LRT)
|
||||
|
||||
_CC = $(_UNIQ)$(CROSS)
|
||||
__CC = $(_CC:$(_UNIQ)=$(CC))
|
||||
MYCC = $(__CC:$(_UNIQ)$(CROSS)=$(CROSS)gcc)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: harness
|
||||
@ -34,20 +33,23 @@ all: harness
|
||||
clean:
|
||||
rm -rf *.o harness harness-debug
|
||||
|
||||
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -O3 -c harness.c
|
||||
harness.o: harness.c ../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -O3 -c harness.c
|
||||
|
||||
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -DAFL_DEBUG=1 -g -c harness.c -o $@
|
||||
harness-debug.o: harness.c ../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -DAFL_DEBUG=1 -g -c harness.c -o $@
|
||||
|
||||
harness: harness.o
|
||||
${MYCC} -L${LIBDIR} harness.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
||||
${CC} harness.o ../../unicornafl/build/libunicornafl.a $(LDFLAGS) -o $@
|
||||
|
||||
debug: harness-debug.o
|
||||
${MYCC} -L${LIBDIR} harness-debug.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
${CC} harness-debug.o ../../unicornafl/build/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
|
||||
../../unicornafl/build/libunicornafl.a:
|
||||
cd ../.. && ./build_unicorn_support.sh
|
||||
|
||||
fuzz: harness
|
||||
../../../afl-fuzz -m none -i sample_inputs -o out -- ./harness @@
|
||||
DYLD_FALLBACK_LIBRARY_PATH="../../unicornafl/unicorn/build" LD_LIBRARY_PATH="../../unicornafl/unicorn/build" ../../../afl-fuzz -m none -i sample_inputs -o out -- ./harness @@
|
||||
|
||||
debugmake:
|
||||
@echo UNAME_S=$(UNAME_S), _LRT=$(_LRT), __LRT=$(__LRT), LRT=$(LRT)
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <unicorn/unicorn.h>
|
||||
#include <unicornafl/unicornafl.h>
|
||||
|
||||
// Path to the file containing the binary to emulate
|
||||
#define BINARY_FILE ("persistent_target_x86_64")
|
||||
|
@ -4,29 +4,28 @@
|
||||
.POSIX:
|
||||
UNAME_S =$(shell uname -s)# GNU make
|
||||
UNAME_S:sh=uname -s # BSD make
|
||||
_UNIQ=_QINU_
|
||||
|
||||
LIBDIR = ../../../unicornafl
|
||||
UNICORNAFL_LIB = ../../../unicornafl/build
|
||||
UNICORN_LIB = ../../../unicornafl/unicorn/build
|
||||
BIN_EXT =
|
||||
AR_EXT = a
|
||||
|
||||
# Verbose output?
|
||||
V ?= 0
|
||||
|
||||
CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -I../../../unicornafl/include
|
||||
CFLAGS += -Wall -I../../../unicornafl/unicorn/include -I../../../unicornafl/include
|
||||
|
||||
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
||||
LDFLAGS += -L$(UNICORNAFL_LIB) -L$(UNICORN_LIB) -lpthread -lm -lunicornafl -lunicorn -lc++
|
||||
|
||||
_LRT = $(_UNIQ)$(UNAME_S:Linux=)
|
||||
__LRT = $(_LRT:$(_UNIQ)=-lrt)
|
||||
LRT = $(__LRT:$(_UNIQ)=)
|
||||
ifeq ($(UNAME), Linux)
|
||||
# do something Linux-y
|
||||
LRT = -lrt
|
||||
else
|
||||
LRT =
|
||||
endif
|
||||
|
||||
LDFLAGS += $(LRT)
|
||||
|
||||
_CC = $(_UNIQ)$(CROSS)
|
||||
__CC = $(_CC:$(_UNIQ)=$(CC))
|
||||
MYCC = $(__CC:$(_UNIQ)$(CROSS)=$(CROSS)gcc)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: ../target harness
|
||||
@ -38,17 +37,20 @@ afl-fuzz: ../../../../afl-fuzz
|
||||
clean:
|
||||
rm -rf *.o harness harness-debug
|
||||
|
||||
harness.o: harness.c ../../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -O3 -c harness.c -o $@
|
||||
../../../unicornafl/build/libunicornafl.a:
|
||||
cd ../../.. && ./build_unicorn_support.sh
|
||||
|
||||
harness-debug.o: harness.c ../../../unicornafl/include/unicorn/*.h
|
||||
${MYCC} ${CFLAGS} -fsanitize=address -g -Og -c harness.c -o $@
|
||||
harness.o: harness.c ../../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -O3 -c harness.c -o $@
|
||||
|
||||
harness-debug.o: harness.c ../../../unicornafl/unicorn/include/unicorn/*.h
|
||||
${CC} ${CFLAGS} -fsanitize=address -g -Og -c harness.c -o $@
|
||||
|
||||
harness: harness.o
|
||||
${MYCC} -L${LIBDIR} harness.o ../../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
||||
${CC} harness.o $(LDFLAGS) -o $@
|
||||
|
||||
harness-debug: harness-debug.o
|
||||
${MYCC} -fsanitize=address -g -Og -L${LIBDIR} harness-debug.o ../../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
${CC} -fsanitize=address -g -Og harness-debug.o ../../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
||||
|
||||
../target:
|
||||
$(MAKE) -C ..
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <unicorn/unicorn.h>
|
||||
#include <unicornafl/unicornafl.h>
|
||||
|
||||
// Path to the file containing the binary to emulate
|
||||
#define BINARY_FILE ("../target")
|
||||
@ -124,7 +125,7 @@ static void mem_map_checked(uc_engine *uc, uint64_t addr, size_t size, uint32_t
|
||||
//printf("SIZE %llx, align: %llx\n", size, ALIGNMENT);
|
||||
uc_err err = uc_mem_map(uc, addr, size, mode);
|
||||
if (err != UC_ERR_OK) {
|
||||
printf("Error mapping %ld bytes at 0x%lx: %s (mode: %d)\n", size, addr, uc_strerror(err), mode);
|
||||
printf("Error mapping %ld bytes at 0x%llx: %s (mode: %d)\n", (unsigned long) size, (unsigned long long) addr, uc_strerror(err), (int) mode);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -306,7 +307,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
exit(-1);
|
||||
}
|
||||
uint64_t start_address;
|
||||
if(fscanf(f, "%lx", &start_address) == EOF) {
|
||||
if(fscanf(f, "%llx", (unsigned long long) &start_address) == EOF) {
|
||||
puts("Start address not found in target.offests.main");
|
||||
exit(-1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user