mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 11:51:13 +00:00
[libFuzzer] remove some old code; also make __sanitizer_get_total_unique_caller_callee_pairs weak so that newer libFuzzer works with older asan
llvm-svn: 251133
This commit is contained in:
parent
c3af29c80c
commit
f03686178a
@ -19,9 +19,6 @@ void FuzzerRandomLibc::ResetSeed(int seed) { srand(seed); }
|
||||
|
||||
size_t FuzzerRandomLibc::Rand() { return rand(); }
|
||||
|
||||
UserSuppliedFuzzer::UserSuppliedFuzzer()
|
||||
: OwnRand(true), Rand(new FuzzerRandomLibc(0)), MD(*Rand) {}
|
||||
|
||||
UserSuppliedFuzzer::UserSuppliedFuzzer(FuzzerRandomBase *Rand)
|
||||
: Rand(Rand), MD(*Rand) {}
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
namespace fuzzer {
|
||||
|
||||
typedef void (*DeprecatedUserCallback)(const uint8_t *Data, size_t Size);
|
||||
/// Returns an int 0. Values other than zero are reserved for future.
|
||||
typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
|
||||
/** Simple C-like interface with a single user-supplied callback.
|
||||
@ -46,7 +45,6 @@ int main(int argc, char **argv) {
|
||||
#\endcode
|
||||
*/
|
||||
int FuzzerDriver(int argc, char **argv, UserCallback Callback);
|
||||
int FuzzerDriver(int argc, char **argv, DeprecatedUserCallback Callback);
|
||||
|
||||
class FuzzerRandomBase {
|
||||
public:
|
||||
@ -137,7 +135,6 @@ int main(int argc, char **argv) {
|
||||
*/
|
||||
class UserSuppliedFuzzer {
|
||||
public:
|
||||
UserSuppliedFuzzer(); // Deprecated, don't use.
|
||||
UserSuppliedFuzzer(FuzzerRandomBase *Rand);
|
||||
/// Executes the target function on 'Size' bytes of 'Data'.
|
||||
virtual int TargetFunction(const uint8_t *Data, size_t Size) = 0;
|
||||
|
@ -186,17 +186,11 @@ class SimpleUserSuppliedFuzzer: public UserSuppliedFuzzer {
|
||||
SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, UserCallback Callback)
|
||||
: UserSuppliedFuzzer(Rand), Callback(Callback) {}
|
||||
|
||||
SimpleUserSuppliedFuzzer(FuzzerRandomBase *Rand, DeprecatedUserCallback Callback)
|
||||
: UserSuppliedFuzzer(Rand), DeprecatedCallback(Callback) {}
|
||||
|
||||
virtual int TargetFunction(const uint8_t *Data, size_t Size) override {
|
||||
if (Callback) return Callback(Data, Size);
|
||||
DeprecatedCallback(Data, Size);
|
||||
return 0;
|
||||
return Callback(Data, Size);
|
||||
}
|
||||
|
||||
private:
|
||||
DeprecatedUserCallback DeprecatedCallback = nullptr;
|
||||
UserCallback Callback = nullptr;
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
extern "C" {
|
||||
__attribute__((weak)) void __sanitizer_print_stack_trace();
|
||||
__attribute__((weak)) size_t __sanitizer_get_total_unique_caller_callee_pairs();
|
||||
}
|
||||
|
||||
namespace fuzzer {
|
||||
@ -207,6 +208,8 @@ size_t Fuzzer::RecordBlockCoverage() {
|
||||
size_t Fuzzer::RecordCallerCalleeCoverage() {
|
||||
if (!Options.UseIndirCalls)
|
||||
return 0;
|
||||
if (!__sanitizer_get_total_unique_caller_callee_pairs)
|
||||
return 0;
|
||||
return LastRecordedCallerCalleeCoverage =
|
||||
__sanitizer_get_total_unique_caller_callee_pairs();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user