You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
6.4 KiB

##############################################################
#
# This file includes all the test targets as well as all the
# non-default build rules and test recipes.
#
##############################################################
##############################################################
#
# Test targets
#
##############################################################
###### Place all generic definitions here ######
# This defines tests which run tools of the same name. This is simply for convenience to avoid
# defining the test name twice (once in TOOL_ROOTS and again in TEST_ROOTS).
# Tests defined here should not be defined in TOOL_ROOTS and TEST_ROOTS.
TEST_TOOL_ROOTS := indirect_jmp_with_translation memory_addr_callback memory_callback_error memory_addr_callback_then rewrite_memory_ptr
# This defines the tests to be run that were not already defined in TEST_TOOL_ROOTS.
TEST_ROOTS :=
# This defines the tools which will be run during the the tests, and were not already defined in
# TEST_TOOL_ROOTS.
TOOL_ROOTS :=
# This defines the static analysis tools which will be run during the the tests. They should not
# be defined in TEST_TOOL_ROOTS. If a test with the same name exists, it should be defined in
# TEST_ROOTS.
# Note: Static analysis tools are in fact executables linked with the Pin Static Analysis Library.
# This library provides a subset of the Pin APIs which allows the tool to perform static analysis
# of an application or dll. Pin itself is not used when this tool runs.
SA_TOOL_ROOTS :=
# This defines all the applications that will be run during the tests.
APP_ROOTS := indirect_jmp
# This defines any additional object files that need to be compiled.
OBJECT_ROOTS :=
# This defines any additional dlls (shared objects), other than the pintools, that need to be compiled.
DLL_ROOTS :=
# This defines any static libraries (archives), that need to be built.
LIB_ROOTS :=
###### Place OS-specific definitions here ######
#Linux
ifeq ($(TARGET_OS),linux)
ifeq ($(TARGET),intel64)
# There are not enough bits on ia32 to mark addresses returned by malloc()
TEST_TOOL_ROOTS += malloc_translation translate_32bit_register
APP_ROOTS += malloc_translation_app translate_32bit_register_app
endif
endif
###### Handle exceptions here ######
# see mantis 4822
ifeq ($(TARGET),ia32)
ifeq ($(TARGET_OS),linux)
ifeq ($(DIST_NAME_UBUNTU),1)
DIST_VER_GE_1910 := $(shell $(TOOLS_ROOT)/Utils/testLinuxDistVersion ge 19.10)
ifeq ($(DIST_VER_GE_1910),1)
TEST_TOOL_ROOTS := $(filter-out indirect_jmp_with_translation, $(TEST_TOOL_ROOTS))
endif
endif
endif
endif
###### Define the sanity subset ######
# This defines the list of tests that should run in sanity. It should include all the tests listed in
# TEST_TOOL_ROOTS and TEST_ROOTS excluding only unstable tests.
SANITY_SUBSET := $(TEST_TOOL_ROOTS) $(TEST_ROOTS)
##############################################################
#
# Test recipes
#
##############################################################
# This section contains recipes for tests other than the default.
# See makefile.default.rules for the default test rules.
# All tests in this section should adhere to the naming convention: <testname>.test
# Test that IARG_BRANCH_TARGET_ADDR works on indirect branch when its target is in memory
indirect_jmp_with_translation.test: $(OBJDIR)indirect_jmp_with_translation$(PINTOOL_SUFFIX) $(OBJDIR)indirect_jmp$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)indirect_jmp_with_translation$(PINTOOL_SUFFIX) -o $(OBJDIR)indirect_jmp_with_translation.out \
-- $(OBJDIR)indirect_jmp$(EXE_SUFFIX)
$(RM) $(OBJDIR)indirect_jmp_with_translation.out
memory_addr_callback.test: $(OBJDIR)memory_addr_callback$(PINTOOL_SUFFIX)
$(PIN) -t $(OBJDIR)memory_addr_callback$(PINTOOL_SUFFIX) \
-- $(TESTAPP) makefile $(OBJDIR)memory_addr_callback.makefile.copy
$(CMP) makefile $(OBJDIR)memory_addr_callback.makefile.copy
$(RM) $(OBJDIR)memory_addr_callback.makefile.copy
memory_callback_error.test: $(OBJDIR)memory_callback_error$(PINTOOL_SUFFIX)
-$(PIN) -logfile $(OBJDIR)memory_callback_error.log -t $(OBJDIR)memory_callback_error$(PINTOOL_SUFFIX) \
-- $(TESTAPP) makefile $(OBJDIR)memory_callback_error.makefile.copy
$(QGREP) "Illegal use of memory address callback and register parameters" $(OBJDIR)memory_callback_error.log
$(RM) $(OBJDIR)memory_callback_error.log
$(RM) -f $(OBJDIR)memory_callback_error.makefile.copy # this file might not be generated so we use the -f flag
malloc_translation.test: $(OBJDIR)malloc_translation$(PINTOOL_SUFFIX) $(OBJDIR)malloc_translation_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)malloc_translation$(PINTOOL_SUFFIX) \
-- $(OBJDIR)malloc_translation_app$(EXE_SUFFIX) `$(CXX) $(COMP_OBJ) /dev/null -print-file-name=libm.so.6` \
> $(OBJDIR)malloc_translation.out 2>&1
$(QGREP) "Application finished successfully!" $(OBJDIR)malloc_translation.out
$(RM) $(OBJDIR)malloc_translation.out
translate_32bit_register.test: $(OBJDIR)translate_32bit_register$(PINTOOL_SUFFIX) $(OBJDIR)translate_32bit_register_app$(EXE_SUFFIX)
$(PIN) -t $(OBJDIR)translate_32bit_register$(PINTOOL_SUFFIX) \
-- $(OBJDIR)translate_32bit_register_app$(EXE_SUFFIX) > $(OBJDIR)translate_32bit_register.out 2>&1
$(QGREP) "result = deadbee" $(OBJDIR)translate_32bit_register.out
$(RM) $(OBJDIR)translate_32bit_register.out
memory_addr_callback_then.test: $(OBJDIR)memory_addr_callback_then$(PINTOOL_SUFFIX)
$(PIN) -t $(OBJDIR)memory_addr_callback_then$(PINTOOL_SUFFIX) \
-- $(TESTAPP) makefile $(OBJDIR)memory_addr_callback_then.makefile.copy
$(CMP) makefile $(OBJDIR)memory_addr_callback_then.makefile.copy
$(RM) $(OBJDIR)memory_addr_callback_then.makefile.copy
rewrite_memory_ptr.test: $(OBJDIR)rewrite_memory_ptr$(PINTOOL_SUFFIX)
$(PIN) -t $(OBJDIR)rewrite_memory_ptr$(PINTOOL_SUFFIX) \
-- $(TESTAPP) makefile $(OBJDIR)rewrite_memory_ptr.makefile.copy
$(CMP) makefile $(OBJDIR)rewrite_memory_ptr.makefile.copy
$(RM) $(OBJDIR)rewrite_memory_ptr.makefile.copy
##############################################################
#
# Build rules
#
##############################################################
# This section contains the build rules for all binaries that have special build rules.
# See makefile.default.rules for the default build rules.
###### Special objects' build rules ######
$(OBJDIR)indirect_jmp$(EXE_SUFFIX): $(OBJDIR)indirect_jmp$(OBJ_SUFFIX)
$(LINKER) $(APP_LDFLAGS_LINK_ASM) $(LINK_EXE)$@ $(PIE) $<