[libFuzzer] add linux-specific test for gc-sections

llvm-svn: 313421
This commit is contained in:
Kostya Serebryany 2017-09-15 23:07:18 +00:00
parent 296f0e294e
commit 80e9a6ccd1
2 changed files with 27 additions and 0 deletions

View File

@ -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;
}

View File

@ -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