Aaron Ballman | ef11698 | 2015-01-29 16:58:29 +0000 | [diff] [blame] | 1 | //===- FuzzerMain.cpp - main() function and flags -------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // main() and flags. |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | |
Kostya Serebryany | 016852c | 2015-02-19 18:45:37 +0000 | [diff] [blame] | 12 | #include "FuzzerInterface.h" |
Aaron Ballman | ef11698 | 2015-01-29 16:58:29 +0000 | [diff] [blame] | 13 | #include "FuzzerInternal.h" |
| 14 | |
Kostya Serebryany | aca7696 | 2016-01-16 01:23:12 +0000 | [diff] [blame^] | 15 | extern "C" { |
Kostya Serebryany | 016852c | 2015-02-19 18:45:37 +0000 | [diff] [blame] | 16 | // This function should be defined by the user. |
Kostya Serebryany | aca7696 | 2016-01-16 01:23:12 +0000 | [diff] [blame^] | 17 | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); |
| 18 | // This function may optionally be defined by the user. |
| 19 | __attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv); |
| 20 | } // extern "C" |
Kostya Serebryany | e8cee11 | 2015-01-31 01:14:40 +0000 | [diff] [blame] | 21 | |
Aaron Ballman | ef11698 | 2015-01-29 16:58:29 +0000 | [diff] [blame] | 22 | int main(int argc, char **argv) { |
Kostya Serebryany | aca7696 | 2016-01-16 01:23:12 +0000 | [diff] [blame^] | 23 | if (LLVMFuzzerInitialize) |
| 24 | LLVMFuzzerInitialize(&argc, &argv); |
Kostya Serebryany | 566bc5a | 2015-05-06 22:19:00 +0000 | [diff] [blame] | 25 | return fuzzer::FuzzerDriver(argc, argv, LLVMFuzzerTestOneInput); |
Aaron Ballman | ef11698 | 2015-01-29 16:58:29 +0000 | [diff] [blame] | 26 | } |