-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from chaoticgd/fuzzing
Add fuzzing harness and fix some bugs it found
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This file is part of the Chaos Compiler Collection. | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "ccc/ccc.h" | ||
|
||
using namespace ccc; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const u8* data, size_t size) | ||
{ | ||
std::vector<u8> image(data, data + size); | ||
Result<std::unique_ptr<SymbolFile>> symbol_file = | ||
parse_symbol_file(std::move(image), "totallyrealvideogame.elf"); | ||
if (!symbol_file.success()) { | ||
return 0; | ||
} | ||
|
||
Result<std::vector<std::unique_ptr<SymbolTable>>> symbol_tables = | ||
(*symbol_file)->get_all_symbol_tables(); | ||
if (!symbol_tables.success()) { | ||
return 0; | ||
} | ||
|
||
SymbolDatabase database; | ||
|
||
DemanglerFunctions demangler; // Don't fuzz the demangler. | ||
|
||
Result<ModuleHandle> module_handle = import_symbol_tables( | ||
database, | ||
(*symbol_file)->name(), | ||
*symbol_tables, | ||
NO_IMPORTER_FLAGS, | ||
demangler, | ||
nullptr); | ||
|
||
return 0; | ||
} |