diff options
| author | Christian Holler (:decoder) <choller@mozilla.com> | 2019-10-17 14:09:49 +0200 |
|---|---|---|
| committer | Christian Holler (:decoder) <choller@mozilla.com> | 2019-10-17 14:09:49 +0200 |
| commit | a2feb9c6cc343a25ecca5594acff61bb92ab4e22 (patch) | |
| tree | 8a7595348cf2d5360d81eebb56e9b172ade26e31 /src/test | |
| parent | a16dca337de610986252bb800953e57bf395863f (diff) | |
| download | rust-a2feb9c6cc343a25ecca5594acff61bb92ab4e22.tar.gz rust-a2feb9c6cc343a25ecca5594acff61bb92ab4e22.zip | |
Avoid injecting sanitizer runtimes into staticlibs (#64629).
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile | 14 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/sanitizer-staticlib-link/program.rs | 10 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile index 200dc1be4de..f56475b441f 100644 --- a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile @@ -4,12 +4,18 @@ -include ../tools.mk -# This test builds a staticlib, then an executable that links to it. -# The staticlib and executable both are compiled with address sanitizer, -# and we assert that a fault in the staticlib is correctly detected. +# This test first builds a staticlib with AddressSanitizer and checks that +# linking it to an executable fails due to the missing sanitizer runtime. +# It then builds an executable linking to the staticlib and checks that +# the fault in the staticlib is detected correctly. + +# Note that checking for the link failure actually checks two things at once: +# 1) That the library has the sanitizer intrumentation +# 2) and that library does not have the sanitizer runtime all: $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs - $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) + ! $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -L . program.rs LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.rs b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.rs new file mode 100644 index 00000000000..21e1ade2cd5 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.rs @@ -0,0 +1,10 @@ +#[link(name = "library")] +extern { + fn overflow(); +} + +fn main() { + unsafe { + overflow(); + } +} |
