VirtualBox

source: vbox/trunk/include/iprt/asmdefs-arm.h@ 106625

最後變更 在這個檔案從106625是 106625,由 vboxsync 提交於 5 月 前

SUPDrv: Making it build on win.arm64... jiraref:VBP-1253

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.1 KB
 
1/** @file
2 * IPRT - ARM Specific Assembly Macros.
3 */
4
5/*
6 * Copyright (C) 2023-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.alldomusa.eu.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_asmdefs_arm_h
37#define IPRT_INCLUDED_asmdefs_arm_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/cdefs.h>
43
44
45#if !defined(RT_ARCH_ARM64) && !defined(RT_ARCH_ARM32)
46# error "Not on ARM64 or ARM32"
47#endif
48
49/** @defgroup grp_rt_asmdefs_arm ARM Specific ASM (Clang and gcc) Macros
50 * @ingroup grp_rt_asm
51 * @{
52 */
53
54/**
55 * Align code, pad with BRK. */
56#define ALIGNCODE(alignment) .balignl alignment, 0xd4201980
57
58/**
59 * Align data, pad with ZEROs. */
60#define ALIGNDATA(alignment) .balign alignment
61
62/**
63 * Align BSS, pad with ZEROs. */
64#define ALIGNBSS(alignment) .balign alignment
65
66
67/** Marks the beginning of a code section. */
68#ifdef ASM_FORMAT_MACHO
69# define BEGINCODE .section __TEXT,__text,regular,pure_instructions
70#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
71# define BEGINCODE .section .text
72#else
73# error "Port me!"
74#endif
75
76/** Marks the end of a code section. */
77#ifdef ASM_FORMAT_MACHO
78# define ENDCODE
79#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
80# define ENDCODE
81#else
82# error "Port me!"
83#endif
84
85
86/** Marks the beginning of a data section. */
87#ifdef ASM_FORMAT_MACHO
88# define BEGINDATA .section __DATA,__data
89#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
90# define BEGINDATA .section .data
91#else
92# error "Port me!"
93#endif
94
95/** Marks the end of a data section. */
96#ifdef ASM_FORMAT_MACHO
97# define ENDDATA
98#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
99# define ENDDATA
100#else
101# error "Port me!"
102#endif
103
104
105/** Marks the beginning of a readonly data section. */
106#ifdef ASM_FORMAT_MACHO
107# define BEGINCONST .section __RODATA,__rodata
108#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
109# define BEGINCONST .section .rodata
110#else
111# error "Port me!"
112#endif
113
114/** Marks the end of a readonly data section. */
115#ifdef ASM_FORMAT_MACHO
116# define ENDCONST
117#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
118# define ENDCONST
119#else
120# error "Port me!"
121#endif
122
123
124/** Marks the beginning of a readonly C strings section. */
125#ifdef ASM_FORMAT_MACHO
126# define BEGINCONSTSTRINGS .section __TEXT,__cstring,cstring_literals
127#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
128# define BEGINCONSTSTRINGS .section .rodata
129#else
130# error "Port me!"
131#endif
132
133/** Marks the end of a readonly C strings section. */
134#ifdef ASM_FORMAT_MACHO
135# define ENDCONSTSTRINGS
136#elif defined(ASM_FORMAT_ELF) || defined(ASM_FORMAT_PE)
137# define ENDCONSTSTRINGS
138#else
139# error "Port me!"
140#endif
141
142
143/**
144 * Mangles the name so it can be referenced using DECLASM() in the C/C++ world.
145 *
146 * @returns a_SymbolC with the necessary prefix/postfix.
147 * @param a_SymbolC A C symbol name to mangle as needed.
148 */
149#if defined(RT_OS_DARWIN)
150# define NAME(a_SymbolC) _ ## a_SymbolC
151#else
152# define NAME(a_SymbolC) a_SymbolC
153#endif
154
155
156/**
157 * Returns the page address of the given symbol (used with the adrp instruction primarily).
158 *
159 * @returns Page aligned address of the given symbol
160 * @param a_Symbol The symbol to get the page address from.
161 */
162#if defined(__clang__)
163# define PAGE(a_Symbol) a_Symbol ## @PAGE
164#elif defined(__GNUC__)
165# define PAGE(a_Symbol) a_Symbol
166#else
167# error "Port me!"
168#endif
169
170/**
171 * Returns the offset inside the page of the given symbol.
172 *
173 * @returns Page offset of the given symbol inside a page.
174 * @param a_Symbol The symbol to get the page offset from.
175 */
176#if defined(__clang__)
177# define PAGEOFF(a_Symbol) a_Symbol ## @PAGEOFF
178#elif defined(__GNUC__)
179# define PAGEOFF(a_Symbol) :lo12: ## a_Symbol
180#else
181# error "Port me!"
182#endif
183
184
185/**
186 * Starts an externally visible procedure.
187 *
188 * @param a_Name The unmangled symbol name.
189 */
190.macro BEGINPROC, a_Name
191NAME(\a_Name):
192.endm
193
194
195/**
196 * Starts a procedure with hidden visibility.
197 *
198 * @param a_Name The unmangled symbol name.
199 */
200.macro BEGINPROC_HIDDEN, a_Name
201#ifdef ASM_FORMAT_MACHO
202 .private_extern NAME(\a_Name)
203#elif defined(ASM_FORMAT_ELF)
204 .hidden NAME(\a_Name)
205#elif defined(ASM_FORMAT_PE)
206 .def NAME(\a_Name)
207 .type 32 /* function */
208 .endef
209#endif
210 .globl NAME(\a_Name)
211NAME(\a_Name):
212.endm
213
214
215/**
216 * Starts an exported procedure.
217 *
218 * @param a_Name The unmangled symbol name.
219 */
220.macro BEGINPROC_EXPORTED, a_Name
221#ifdef ASM_FORMAT_MACHO
222 //.private_extern NAME(\a_Name)
223#elif defined(ASM_FORMAT_ELF)
224 //.hidden NAME(\a_Name)
225#elif defined(ASM_FORMAT_PE)
226 .pushsection .drectve
227 .string "-export:\a_Name"
228 .popsection
229 .def NAME(\a_Name)
230 .type 32 /* function */
231 .endef
232#endif
233 .globl NAME(\a_Name)
234NAME(\a_Name):
235.endm
236
237
238/**
239 * Ends a procedure.
240 *
241 * @param a_Name The unmangled symbol name.
242 */
243.macro ENDPROC, a_Name
244NAME(\a_Name)\()_EndProc:
245.endm
246
247
248/** @} */
249
250#endif /* !IPRT_INCLUDED_asmdefs_arm_h */
251
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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