2017-06-17 13:42:56 +10:00
|
|
|
-include ../tools.mk
|
|
|
|
|
2017-09-07 13:36:23 -07:00
|
|
|
LOG := $(TMPDIR)/log.txt
|
|
|
|
|
2017-06-17 13:42:56 +10:00
|
|
|
# This test builds a shared object, then an executable that links it as a native
|
|
|
|
# rust library (constrast to an rlib). The shared library and executable both
|
|
|
|
# are compiled with address sanitizer, and we assert that a fault in the dylib
|
|
|
|
# is correctly detected.
|
|
|
|
|
|
|
|
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
|
|
|
|
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
|
2017-09-07 13:36:23 -07:00
|
|
|
|
|
|
|
# See comment in sanitizer-address/Makefile for why this is here
|
|
|
|
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
|
2017-06-17 13:42:56 +10:00
|
|
|
endif
|
|
|
|
|
|
|
|
all:
|
|
|
|
ifeq ($(ASAN_SUPPORT),1)
|
2017-09-07 13:36:23 -07:00
|
|
|
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
|
|
|
|
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
|
2017-11-23 23:19:50 +08:00
|
|
|
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
|
2017-06-17 13:42:56 +10:00
|
|
|
endif
|