LCOV - code coverage report
Current view: top level - util/sanitize - fd_msan.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 2 3 66.7 %
Date: 2024-11-13 11:58:15 Functions: 8 1965 0.4 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_util_sanitize_fd_msan_h
       2             : #define HEADER_fd_src_util_sanitize_fd_msan_h
       3             : 
       4             : #include "../fd_util_base.h"
       5             : 
       6             : /* MemorySanitizer (MSan) detects uninitialized access via a global
       7             :    bitmap.
       8             : 
       9             :    More info on MSan:
      10             :      - https://clang.llvm.org/docs/MemorySanitizer.html
      11             :      - https://github.com/google/sanitizers/wiki/MemorySanitizer */
      12             : 
      13             : /* Based on https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/sanitizer/msan_interface.h
      14             : 
      15             :    Part of the LLVM Project, under the Apache License v2.0 with LLVM
      16             :    Exceptions.  See https://llvm.org/LICENSE.txt for license
      17             :    information.  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
      18             : 
      19             :    This file was originally part of MemorySanitizer (MSan). */
      20             : 
      21             : #ifndef FD_HAS_MSAN
      22             : #if defined(__has_feature)
      23             : #define FD_HAS_MSAN __has_feature(memory_sanitizer)
      24             : #else
      25             : #define FD_HAS_MSAN 0
      26             : #endif
      27             : #endif
      28             : 
      29             : #if FD_HAS_MSAN
      30             : #define FD_FN_NO_MSAN __attribute__((no_sanitize("memory")))
      31             : #else
      32             : #define FD_FN_NO_MSAN
      33             : #endif
      34             : 
      35             : FD_PROTOTYPES_BEGIN
      36             : 
      37             : #if FD_HAS_MSAN
      38             : 
      39             : /* These are for internal use only */
      40             : 
      41             : void __msan_poison                  ( void const volatile * addr, ulong sz );
      42             : void __msan_unpoison                ( void const volatile * addr, ulong sz );
      43             : void __msan_check_mem_is_initialized( void const volatile * addr, ulong sz );
      44             : 
      45             : static inline void * fd_msan_poison  ( void *       addr, ulong sz ) { __msan_poison  ( addr, sz ); return addr; }
      46             : static inline void * fd_msan_unpoison( void *       addr, ulong sz ) { __msan_unpoison( addr, sz ); return addr; }
      47             : static inline void   fd_msan_check   ( void const * addr, ulong sz ) { __msan_check_mem_is_initialized( addr, sz ); }
      48             : 
      49             : #else
      50             : 
      51           0 : static inline void * fd_msan_poison  ( void *       addr, ulong sz ) { (void)sz; return addr; }
      52   321924551 : static inline void * fd_msan_unpoison( void *       addr, ulong sz ) { (void)sz; return addr; }
      53   585407428 : static inline void   fd_msan_check   ( void const * addr, ulong sz ) { (void)addr; (void)sz; }
      54             : 
      55             : #endif
      56             : 
      57             : FD_PROTOTYPES_END
      58             : 
      59             : #endif /* HEADER_fd_src_util_sanitize_fd_msan_h */

Generated by: LCOV version 1.14