diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-19 13:47:45 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-19 14:01:35 +0300 |
commit | 61b92aeb846ebc6180fb4c18c85ff10c58093610 (patch) | |
tree | 12548033bf36969184a00836dcbbdc8b14a7da2c /contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp | |
parent | 28b29535ce7b21a3dde60b485c98f66f8c08f882 (diff) | |
download | ydb-61b92aeb846ebc6180fb4c18c85ff10c58093610.tar.gz |
Intermediate changes
commit_hash:ebf6fb6dff099bd6bcfbf201e52dda1751dd76fd
Diffstat (limited to 'contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp')
-rw-r--r-- | contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp b/contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp index 688bad1d51c..566820ae6d1 100644 --- a/contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp +++ b/contrib/libs/libfuzzer/lib/fuzzer/FuzzerExtFunctionsWindows.cpp @@ -14,6 +14,7 @@ #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" +#include <stdlib.h> using namespace fuzzer; @@ -22,6 +23,11 @@ using namespace fuzzer; #define STRINGIFY(A) STRINGIFY_(A) #if LIBFUZZER_MSVC +#define GET_FUNCTION_ADDRESS(fn) &fn +#else +#define GET_FUNCTION_ADDRESS(fn) __builtin_function_start(fn) +#endif // LIBFUZER_MSVC + // Copied from compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h #if defined(_M_IX86) || defined(__i386__) #define WIN_SYM_PREFIX "_" @@ -31,17 +37,9 @@ using namespace fuzzer; // 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( \ +#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) \ @@ -57,20 +55,23 @@ extern "C" { } template <typename T> -static T *GetFnPtr(T *Fun, T *FunDef, const char *FnName, bool WarnIfMissing) { +static T *GetFnPtr(void *Fun, void *FunDef, const char *FnName, + bool WarnIfMissing) { if (Fun == FunDef) { if (WarnIfMissing) Printf("WARNING: Failed to find function \"%s\".\n", FnName); return nullptr; } - return Fun; + return (T *)Fun; } namespace fuzzer { ExternalFunctions::ExternalFunctions() { -#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ - this->NAME = GetFnPtr<decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN); +#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \ + this->NAME = GetFnPtr<decltype(::NAME)>(GET_FUNCTION_ADDRESS(::NAME), \ + GET_FUNCTION_ADDRESS(::NAME##Def), \ + #NAME, WARN); #include "FuzzerExtFunctions.def" |