Skip to content

Commit 4b1978c

Browse files
authored
Merge pull request #38023 from al45tair/sr-14813
[SR-14813] [Fuzzers] Fix the mangler and reflection fuzzer build.
2 parents c049951 + 28c0d9d commit 4b1978c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ function(add_swift_fuzzer_host_tool executable)
935935
936936
# Then make sure that we pass the -fsanitize=fuzzer flag both on the cflags
937937
# and cxx flags line.
938-
target_compile_options(${executable} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"-fsanitize=fuzzer">)
938+
target_compile_options(${executable} PRIVATE
939+
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fsanitize=fuzzer>
940+
$<$<COMPILE_LANGUAGE:Swift>:-sanitize=fuzzer>)
939941
target_link_libraries(${executable} PRIVATE "-fsanitize=fuzzer")
940942
endfunction()
941943

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
#include "llvm/Object/ELFObjectFile.h"
2929
#include "llvm/Object/MachOUniversal.h"
3030
#include "llvm/Support/CommandLine.h"
31-
#include <stddef.h>
32-
#include <stdint.h>
31+
#include <cstddef>
32+
#include <cstdint>
33+
#include <cstdio>
3334

3435
#if defined(__APPLE__) && defined(__MACH__)
3536
#include <TargetConditionals.h>
@@ -73,6 +74,16 @@ 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 = static_cast<uintptr_t>(
81+
ptrauth_strip(static_cast<void *>(0x0007ffffffffffff), 0));
82+
#else
83+
*result = ~uintptr_t(0);
84+
#endif
85+
return true;
86+
}
7687
case DLQ_GetSizeSize: {
7788
auto result = static_cast<uint8_t *>(outBuffer);
7889
*result = sizeof(size_t);
@@ -131,6 +142,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
131142
auto reader = std::make_shared<ObjectMemoryReader>();
132143
NativeReflectionContext context(std::move(reader));
133144
context.addImage(RemoteAddress(Data));
134-
context.getBuilder().dumpAllSections(std::cout);
145+
context.getBuilder().dumpAllSections(stdout);
135146
return 0; // Non-zero return values are reserved for future use.
136147
}

0 commit comments

Comments
 (0)