Files
TheRock/compiler/amd-llvm/compiler-rt/lib/fuzzer/FuzzerExtraCountersWindows.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

81 lines
3.1 KiB
C++

//===- FuzzerExtraCountersWindows.cpp - Extra coverage counters for Win32 -===//
//
// 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
//
//===----------------------------------------------------------------------===//
// Extra coverage counters defined by user code for Windows.
//===----------------------------------------------------------------------===//
#include "FuzzerPlatform.h"
#include <cstdint>
#if LIBFUZZER_WINDOWS
#include <windows.h>
namespace fuzzer {
//
// The __start___libfuzzer_extra_counters variable is align 16, size 16 to
// ensure the padding between it and the next variable in this section (either
// __libfuzzer_extra_counters or __stop___libfuzzer_extra_counters) will be
// located at (__start___libfuzzer_extra_counters +
// sizeof(__start___libfuzzer_extra_counters)). Otherwise, the calculation of
// (stop - (start + sizeof(start))) might be skewed.
//
// The section name, __libfuzzer_extra_countaaa ends with "aaa", so it sorts
// before __libfuzzer_extra_counters alphabetically. We want the start symbol to
// be placed in the section just before the user supplied counters (if present).
//
#pragma section(".data$__libfuzzer_extra_countaaa")
ATTRIBUTE_ALIGNED(16)
__declspec(allocate(".data$__libfuzzer_extra_countaaa")) uint8_t
__start___libfuzzer_extra_counters[16] = {0};
//
// Example of what the user-supplied counters should look like. First, the
// pragma to create the section name. It will fall alphabetically between
// ".data$__libfuzzer_extra_countaaa" and ".data$__libfuzzer_extra_countzzz".
// Next, the declspec to allocate the variable inside the specified section.
// Finally, some array, struct, whatever that is used to track the counter data.
// The size of this variable is computed at runtime by finding the difference of
// __stop___libfuzzer_extra_counters and __start___libfuzzer_extra_counters +
// sizeof(__start___libfuzzer_extra_counters).
//
//
// #pragma section(".data$__libfuzzer_extra_counters")
// __declspec(allocate(".data$__libfuzzer_extra_counters"))
// uint8_t any_name_variable[64 * 1024];
//
//
// Here, the section name, __libfuzzer_extra_countzzz ends with "zzz", so it
// sorts after __libfuzzer_extra_counters alphabetically. We want the stop
// symbol to be placed in the section just after the user supplied counters (if
// present). Align to 1 so there isn't any padding placed between this and the
// previous variable.
//
#pragma section(".data$__libfuzzer_extra_countzzz")
ATTRIBUTE_ALIGNED(1)
__declspec(allocate(".data$__libfuzzer_extra_countzzz")) uint8_t
__stop___libfuzzer_extra_counters = 0;
uint8_t *ExtraCountersBegin() {
return __start___libfuzzer_extra_counters +
sizeof(__start___libfuzzer_extra_counters);
}
uint8_t *ExtraCountersEnd() { return &__stop___libfuzzer_extra_counters; }
ATTRIBUTE_NO_SANITIZE_ALL
void ClearExtraCounters() {
uint8_t *Beg = ExtraCountersBegin();
SecureZeroMemory(Beg, ExtraCountersEnd() - Beg);
}
} // namespace fuzzer
#endif