[compiler-rt] r313421 - [libFuzzer] add linux-specific test for gc-sections

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 16:07:18 PDT 2017


Author: kcc
Date: Fri Sep 15 16:07:18 2017
New Revision: 313421

URL: http://llvm.org/viewvc/llvm-project?rev=313421&view=rev
Log:
[libFuzzer] add linux-specific test for gc-sections

Added:
    compiler-rt/trunk/test/fuzzer/GcSectionsTest.cpp
    compiler-rt/trunk/test/fuzzer/gc-sections.test

Added: compiler-rt/trunk/test/fuzzer/GcSectionsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/GcSectionsTest.cpp?rev=313421&view=auto
==============================================================================
--- compiler-rt/trunk/test/fuzzer/GcSectionsTest.cpp (added)
+++ compiler-rt/trunk/test/fuzzer/GcSectionsTest.cpp Fri Sep 15 16:07:18 2017
@@ -0,0 +1,14 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Simple test for a fuzzer.
+// The unused function should not be present in the binary.
+#include <cstddef>
+#include <cstdint>
+
+extern "C" void UnusedFunctionShouldBeRemovedByLinker() { }
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+  return 0;
+}
+

Added: compiler-rt/trunk/test/fuzzer/gc-sections.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/gc-sections.test?rev=313421&view=auto
==============================================================================
--- compiler-rt/trunk/test/fuzzer/gc-sections.test (added)
+++ compiler-rt/trunk/test/fuzzer/gc-sections.test Fri Sep 15 16:07:18 2017
@@ -0,0 +1,13 @@
+REQUIRES: linux
+
+No gc-sections:
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t
+RUN: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+
+With gc-sections. Currently, we can't remove unused code.
+DISABLED: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -Wl,-gc-sections
+DISABLED: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+
+With gc sections, with trace-pc. Unused code is removed.
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -fsanitize-coverage=0 -fsanitize-coverage=trace-pc -ffunction-sections -Wl,-gc-sections
+RUN: nm %t | not grep UnusedFunctionShouldBeRemovedByLinker




More information about the llvm-commits mailing list