[compiler-rt] r344391 - [SanitizerCoverage] Prevent /OPT:REF from stripping constructors

Jonathan Metzman via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 11:11:47 PDT 2018


Author: metzman
Date: Fri Oct 12 11:11:47 2018
New Revision: 344391

URL: http://llvm.org/viewvc/llvm-project?rev=344391&view=rev
Log:
[SanitizerCoverage] Prevent /OPT:REF from stripping constructors

Summary:
Linking with the /OPT:REF linker flag when building COFF files causes
the linker to strip SanitizerCoverage's constructors. Prevent this by
giving the constructors WeakODR linkage and by passing the linker a
directive to include sancov.module_ctor.

Include a test in compiler-rt to verify libFuzzer can be linked using
/OPT:REF

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: rnk, morehouse, hiraditya

Differential Revision: https://reviews.llvm.org/D52119

Added:
    compiler-rt/trunk/test/fuzzer/windows-opt-ref.test

Added: compiler-rt/trunk/test/fuzzer/windows-opt-ref.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/windows-opt-ref.test?rev=344391&view=auto
==============================================================================
--- compiler-rt/trunk/test/fuzzer/windows-opt-ref.test (added)
+++ compiler-rt/trunk/test/fuzzer/windows-opt-ref.test Fri Oct 12 11:11:47 2018
@@ -0,0 +1,9 @@
+REQUIRES: windows
+// Verify that the linker eliminating unreferenced functions (/OPT:REF) does not
+// strip sancov module constructor.
+RUN: %cpp_compiler %S/SimpleCmpTest.cpp -o %t-SimpleCmpTest /link /OPT:REF
+
+RUN: not %run %t-SimpleCmpTest -seed=1 -runs=100000000 2>&1 | FileCheck %s
+
+CHECK-NOT: ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
+CHECK: BINGO




More information about the llvm-commits mailing list