//=== FuzzerExtWindows.cpp - Interface to external functions --------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Implementation of FuzzerExtFunctions for Windows. Uses alternatename when // compiled with MSVC. Uses weak aliases when compiled with clang. Unfortunately // the method each compiler supports is not supported by the other. //===----------------------------------------------------------------------===// #include"FuzzerPlatform.h" #if LIBFUZZER_WINDOWS
// Declare external functions as having alternativenames, so that we can // determine if they are not defined. #define EXTERNAL_FUNC(Name, Default) \
__pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY( \
Name) "=" WIN_SYM_PREFIX STRINGIFY(Default))) #else // Declare external functions as weak to allow them to default to a specified // function if not defined explicitly. We must use weak symbols because clang's // support for alternatename is not 100%, see // https://bugs.llvm.org/show_bug.cgi?id=40218 for more details. #define EXTERNAL_FUNC(Name, Default) \
__attribute__((weak, alias(STRINGIFY(Default)))) #endif// LIBFUZZER_MSVC
extern"C" { #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
RETURN_TYPE NAME##Def FUNC_SIG { \
Printf("ERROR: Function \"%s\" not defined.\n", #NAME); \ exit(1); \
} \
EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG
#include"FuzzerExtFunctions.def"
#undef EXT_FUNC
}
template <typename T> static T *GetFnPtr(T *Fun, T *FunDef, constchar *FnName, bool WarnIfMissing) { if (Fun == FunDef) { if (WarnIfMissing)
Printf("WARNING: Failed to find function \"%s\".\n", FnName); return nullptr;
} return Fun;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.