diff options
author | Kostya Serebryany <kcc@google.com> | 2017-09-15 23:07:18 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2017-09-15 23:07:18 +0000 |
commit | 2fd9c24c1592e3a09f10e5dcb5be89e1dc73b6dd (patch) | |
tree | aa3524719df95f67a0afb49f009dd70cd689f185 /test/fuzzer | |
parent | e0a2ec37f5639468977161a3d93e041b5a2f867b (diff) |
[libFuzzer] add linux-specific test for gc-sections
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/fuzzer')
-rw-r--r-- | test/fuzzer/GcSectionsTest.cpp | 14 | ||||
-rw-r--r-- | test/fuzzer/gc-sections.test | 13 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/fuzzer/GcSectionsTest.cpp b/test/fuzzer/GcSectionsTest.cpp new file mode 100644 index 000000000..fd9da7735 --- /dev/null +++ b/test/fuzzer/GcSectionsTest.cpp @@ -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; +} + diff --git a/test/fuzzer/gc-sections.test b/test/fuzzer/gc-sections.test new file mode 100644 index 000000000..8785bb00e --- /dev/null +++ b/test/fuzzer/gc-sections.test @@ -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 |