1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- mode: C++ -*-
3 //
4 // Copyright 2021-2022 Google LLC
5 //
6 // Licensed under the Apache License v2.0 with LLVM Exceptions (the
7 // "License"); you may not use this file except in compliance with the
8 // License. You may obtain a copy of the License at
9 //
10 // https://llvm.org/LICENSE.txt
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 // Author: Matthias Maennich
19
20 #include <string_view>
21
22 #include "btf_reader.h"
23 #include "error.h"
24 #include "graph.h"
25
LLVMFuzzerTestOneInput(char * data,size_t size)26 extern "C" int LLVMFuzzerTestOneInput(char* data, size_t size) {
27 try {
28 stg::Graph graph;
29 stg::btf::Structs(graph).Process(std::string_view(data, size));
30 } catch (const stg::Exception&) {
31 // Pass as this is us catching invalid BTF properly.
32 }
33 return 0;
34 }
35