mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-30 12:25:49 +00:00
ANYPS5_BUILD_FUZZERS builds relinker_conversion_fuzzer with AddressSanitizer and UndefinedBehaviorSanitizer in relinker-only Clang builds on Linux. The first input byte selects the target system, --to-intel and the unused-filter level; the rest is the executable passed to Conversion::Convert, the path the web converter takes. tools/relinker_fuzz_seeds.py writes the relinker test fixtures as seeds, and CTest runs a short smoke run.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#include <relinker/pipeline/Conversion.hpp>
|
|
#include <io/NativePath.hpp>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <exception>
|
|
#include <string_view>
|
|
|
|
namespace {
|
|
|
|
class SilentProgress final : public Domain::IProgress {
|
|
public:
|
|
void Report(const Domain::ProgressEvent&) override {}
|
|
void Message(std::string_view) override {}
|
|
};
|
|
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) {
|
|
if (size < 1) return 0;
|
|
const std::uint8_t selector = data[0];
|
|
Relinker::ConversionInput input;
|
|
input.InputPath = Io::NativePath("/input/eboot.bin");
|
|
input.OutputPath = Io::NativePath("/output/eboot");
|
|
input.ModuleRoot = "/input";
|
|
input.Executable.assign(data + 1, data + size);
|
|
Relinker::ConversionOptions options;
|
|
switch (selector % 3) {
|
|
case 0: options.Target = Relinker::TargetSystem::Linux; break;
|
|
case 1: options.Target = Relinker::TargetSystem::Windows; break;
|
|
default: options.Target = Relinker::TargetSystem::MacOs; break;
|
|
}
|
|
options.ToIntel = (selector & 0x04) != 0;
|
|
options.UnusedFilterLevel = (selector >> 3) % 3;
|
|
SilentProgress progress;
|
|
try {
|
|
Relinker::Conversion(progress).Convert(std::move(input), options);
|
|
} catch (const std::exception&) {
|
|
}
|
|
return 0;
|
|
}
|