LCOV - code coverage report
Current view: top level - zephyr/linker - utils.h Coverage Total Hit
Test: new.info Lines: 25.0 % 4 1
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2022 Intel Corporation
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : #ifndef ZEPHYR_INCLUDE_LINKER_UTILS_H_
       8              : #define ZEPHYR_INCLUDE_LINKER_UTILS_H_
       9              : 
      10              : #include <stdbool.h>
      11              : 
      12              : /**
      13              :  * @brief Check if address is in read only section.
      14              :  *
      15              :  * Note that this may return false if the address lies outside
      16              :  * the compiler's default read only sections (e.g. .rodata
      17              :  * section), depending on the linker script used. This also
      18              :  * applies to constants with explicit section attributes.
      19              :  *
      20              :  * @param addr Address.
      21              :  *
      22              :  * @return True if address identified within read only section.
      23              :  */
      24            1 : static inline bool linker_is_in_rodata(const void *addr)
      25              : {
      26              : #if defined(CONFIG_LINKER_USE_PINNED_SECTION)
      27              :         extern char lnkr_pinned_rodata_start[];
      28              :         extern char lnkr_pinned_rodata_end[];
      29              : 
      30              :         if (((const char *)addr >= (const char *)lnkr_pinned_rodata_start) &&
      31              :             ((const char *)addr < (const char *)lnkr_pinned_rodata_end)) {
      32              :                 return true;
      33              :         }
      34              : #endif
      35              : 
      36              : #if defined(CONFIG_ARM) || defined(CONFIG_ARC) || defined(CONFIG_X86) || \
      37              :         defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_SPARC) || \
      38              :         defined(CONFIG_MIPS) || defined(CONFIG_XTENSA) || defined(CONFIG_RX)
      39              :         extern char __rodata_region_start[];
      40              :         extern char __rodata_region_end[];
      41              : #define RO_START __rodata_region_start
      42              : #define RO_END   __rodata_region_end
      43              : #else
      44            0 : #define RO_START 0
      45            0 : #define RO_END   0
      46              : #endif
      47              : 
      48              :         return (((const char *)addr >= (const char *)RO_START) &&
      49              :                 ((const char *)addr < (const char *)RO_END));
      50              : 
      51              : #undef RO_START
      52              : #undef RO_END
      53              : }
      54              : 
      55              : #endif /* ZEPHYR_INCLUDE_LINKER_UTILS_H_ */
        

Generated by: LCOV version 2.0-1