Skip to content

Commit a6ec498

Browse files
committed
[SR-14813] [Fuzzers] Fix the mangler and reflection fuzzer build.
The mangler fuzzer and reflection fuzzer build was broken, both by a problem in the CMake scripts and also because of changes that have happened in other parts of the code.
1 parent 775bff0 commit a6ec498

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ function(add_swift_fuzzer_host_tool executable)
885885
886886
# Then make sure that we pass the -fsanitize=fuzzer flag both on the cflags
887887
# and cxx flags line.
888-
target_compile_options(${executable} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"-fsanitize=fuzzer">)
888+
target_compile_options(${executable} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fsanitize=fuzzer>)
889889
target_link_libraries(${executable} PRIVATE "-fsanitize=fuzzer")
890890
endfunction()
891891

tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/Object/ELFObjectFile.h"
2929
#include "llvm/Object/MachOUniversal.h"
3030
#include "llvm/Support/CommandLine.h"
31+
#include <stdio.h>
3132
#include <stddef.h>
3233
#include <stdint.h>
3334

@@ -73,6 +74,15 @@ class ObjectMemoryReader : public MemoryReader {
7374
*result = sizeof(void *);
7475
return true;
7576
}
77+
case DLQ_GetPtrAuthMask: {
78+
auto result = static_cast<uintptr_t *>(outBuffer);
79+
#if __has_feature(ptrauth_calls)
80+
*result = (uintptr_t)ptrauth_strip((void*)0x0007ffffffffffff, 0);
81+
#else
82+
*result = (uintptr_t)~0ull;
83+
#endif
84+
return true;
85+
}
7686
case DLQ_GetSizeSize: {
7787
auto result = static_cast<uint8_t *>(outBuffer);
7888
*result = sizeof(size_t);
@@ -131,6 +141,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
131141
auto reader = std::make_shared<ObjectMemoryReader>();
132142
NativeReflectionContext context(std::move(reader));
133143
context.addImage(RemoteAddress(Data));
134-
context.getBuilder().dumpAllSections(std::cout);
144+
context.getBuilder().dumpAllSections(stdout);
135145
return 0; // Non-zero return values are reserved for future use.
136146
}

0 commit comments

Comments
 (0)