Skip to content

Commit c459207

Browse files
committed
follow the sanitizer change
1 parent 4852120 commit c459207

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

compiler-rt/lib/fuzzer/FuzzerExtFunctionsWindows.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ using namespace fuzzer;
2222
#define STRINGIFY(A) STRINGIFY_(A)
2323

2424
#if LIBFUZZER_MSVC
25+
#define GET_FUNCTION_ADDRESS(fn) &fn
26+
#else
27+
#define GET_FUNCTION_ADDRESS(fn) __builtin_function_start(fn)
28+
#endif // LIBFUZER_MSVC
29+
2530
// Copied from compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h
2631
#if defined(_M_IX86) || defined(__i386__)
2732
#define WIN_SYM_PREFIX "_"
@@ -31,17 +36,9 @@ using namespace fuzzer;
3136

3237
// Declare external functions as having alternativenames, so that we can
3338
// determine if they are not defined.
34-
#define EXTERNAL_FUNC(Name, Default) \
35-
__pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY( \
39+
#define EXTERNAL_FUNC(Name, Default) \
40+
__pragma(comment(linker, "/alternatename:" WIN_SYM_PREFIX STRINGIFY( \
3641
Name) "=" WIN_SYM_PREFIX STRINGIFY(Default)))
37-
#else
38-
// Declare external functions as weak to allow them to default to a specified
39-
// function if not defined explicitly. We must use weak symbols because clang's
40-
// support for alternatename is not 100%, see
41-
// https://bugs.llvm.org/show_bug.cgi?id=40218 for more details.
42-
#define EXTERNAL_FUNC(Name, Default) \
43-
__attribute__((weak, alias(STRINGIFY(Default))))
44-
#endif // LIBFUZZER_MSVC
4542

4643
extern "C" {
4744
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
@@ -57,20 +54,23 @@ extern "C" {
5754
}
5855

5956
template <typename T>
60-
static T *GetFnPtr(T *Fun, T *FunDef, const char *FnName, bool WarnIfMissing) {
57+
static T *GetFnPtr(void *Fun, void *FunDef, const char *FnName,
58+
bool WarnIfMissing) {
6159
if (Fun == FunDef) {
6260
if (WarnIfMissing)
6361
Printf("WARNING: Failed to find function \"%s\".\n", FnName);
6462
return nullptr;
6563
}
66-
return Fun;
64+
return (T *)Fun;
6765
}
6866

6967
namespace fuzzer {
7068

7169
ExternalFunctions::ExternalFunctions() {
72-
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
73-
this->NAME = GetFnPtr<decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN);
70+
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
71+
this->NAME = GetFnPtr<decltype(::NAME)>(GET_FUNCTION_ADDRESS(::NAME), \
72+
GET_FUNCTION_ADDRESS(::NAME##Def), \
73+
#NAME, WARN);
7474

7575
#include "FuzzerExtFunctions.def"
7676

0 commit comments

Comments
 (0)