VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/compiler-vcc.h@ 102792

Last change on this file since 102792 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: compiler-vcc.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Internal header for the Visual C++ Compiler Support Code.
4 */
5
6/*
7 * Copyright (C) 2022-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_INTERNAL_compiler_vcc_h
38#define IPRT_INCLUDED_INTERNAL_compiler_vcc_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/types.h>
44
45/** @name Special sections.
46 * @{
47 */
48
49#ifdef IPRT_COMPILER_VCC_WITH_C_INIT_TERM_SECTIONS
50# pragma section(".CRT$XIA", read, long) /* start C initializers */
51# pragma section(".CRT$XIAA", read, long)
52# pragma section(".CRT$XIZ", read, long)
53
54# pragma section(".CRT$XPA", read, long) /* start early C terminators */
55# pragma section(".CRT$XPAA", read, long)
56# pragma section(".CRT$XPZ", read, long)
57
58# pragma section(".CRT$XTA", read, long) /* start C terminators */
59# pragma section(".CRT$XTAA", read, long)
60# pragma section(".CRT$XTZ", read, long)
61# define IPRT_COMPILER_TERM_CALLBACK(a_fn) \
62 __declspec(allocate(".CRT$XTAA")) PFNRT RT_CONCAT(g_rtVccTermCallback_, a_fn) = a_fn
63#endif
64
65#ifdef IPRT_COMPILER_VCC_WITH_CPP_INIT_SECTIONS
66# pragma warning(disable:5247) /* warning C5247: section '.CRT$XCA' is reserved for C++ dynamic initialization. Manually creating the section will interfere with C++ dynamic initialization and may lead to undefined behavior */
67# pragma warning(disable:5248) /* warning C5248: section '.CRT$XCA' is reserved for C++ dynamic initialization. Variables manually put into the section may be optimized out and their order relative to compiler generated dynamic initializers is unspecified */
68# pragma section(".CRT$XCA", read, long) /* start C++ initializers */
69# pragma section(".CRT$XCAA", read, long)
70# pragma section(".CRT$XCZ", read, long)
71#endif
72
73#ifdef IPRT_COMPILER_VCC_WITH_RTC_INIT_TERM_SECTIONS
74# pragma section(".rtc$IAA", read, long) /* start RTC initializers */
75# pragma section(".rtc$IZZ", read, long)
76
77# pragma section(".rtc$TAA", read, long) /* start RTC terminators */
78# pragma section(".rtc$TZZ", read, long)
79#endif
80
81#ifdef IPRT_COMPILER_VCC_WITH_TLS_CALLBACK_SECTIONS
82# pragma section(".CRT$XLA", read, long) /* start TLS callback */
83# pragma section(".CRT$XLAA", read, long)
84# pragma section(".CRT$XLZ", read, long)
85
86/** @todo what about .CRT$XDA? Dynamic TLS initializers. */
87#endif
88
89#ifdef IPRT_COMPILER_VCC_WITH_TLS_DATA_SECTIONS
90# pragma section(".tls", read, long) /* start TLS callback */
91# pragma section(".tls$ZZZ", read, long)
92
93/** @todo what about .CRT$XDA? Dynamic TLS initializers. */
94#endif
95
96/** @} */
97
98
99RT_C_DECLS_BEGIN
100
101extern unsigned _fltused;
102
103void rtVccInitSecurityCookie(void) RT_NOEXCEPT;
104void rtVccWinInitBssOnNt3(void *pvImageBase) RT_NOEXCEPT;
105void rtVccWinInitProcExecPath(void) RT_NOEXCEPT;
106int rtVccInitializersRunInit(void) RT_NOEXCEPT;
107void rtVccInitializersRunTerm(void) RT_NOEXCEPT;
108void rtVccTermRunAtExit(void) RT_NOEXCEPT;
109
110struct _CONTEXT;
111void rtVccCheckContextFailed(struct _CONTEXT *pCpuCtx);
112
113#ifdef _CONTROL_FLOW_GUARD
114DECLASM(void) __guard_check_icall_nop(uintptr_t); /**< nocrt-guard-win.asm */
115#endif
116extern uintptr_t __guard_check_icall_fptr; /**< nocrt-guard-win.asm */
117
118RT_C_DECLS_END
119
120
121/**
122 * Checks if CFG is currently active.
123 *
124 * This requires CFG to be enabled at compile time, supported by the host OS
125 * version and activated by the module loader.
126 *
127 * @returns true if CFG is active, false if not.
128 */
129DECLINLINE(bool) rtVccIsGuardICallChecksActive(void)
130{
131#ifdef _CONTROL_FLOW_GUARD
132 return __guard_check_icall_fptr != (uintptr_t)__guard_check_icall_nop;
133#else
134 return false;
135#endif
136}
137
138
139#ifdef IPRT_INCLUDED_nt_nt_h
140/**
141 * Checks if a pointer is on the officially registered stack or not.
142 *
143 * @returns true if on the official stack, false if not.
144 * @param uStackPtr The pointer to check.
145 */
146DECLINLINE(bool) rtVccIsPointerOnTheStack(uintptr_t uStackPtr)
147{
148 PNT_TIB const pTib = (PNT_TIB)RTNtCurrentTeb();
149 return uStackPtr <= (uintptr_t)pTib->StackBase
150 && uStackPtr >= (uintptr_t)pTib->StackLimit;
151}
152#endif
153
154#endif /* !IPRT_INCLUDED_INTERNAL_compiler_vcc_h */
155
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette