// // symcryptasm_shared.cppasm Shared definitions used by the C preprocessor step in symcryptasm // processing. See scripts/symcryptasm_processor.py for more details. // // Copyright (c) Microsoft Corporation. Licensed under the MIT license. // #include "C_asm_shared.inc" // Platform-specific name mangling // ARM64EC needs to use a modified function name as the code can co-exist with equivalent ARM64 code. // macOS (Mach-O) needs to prefix all C symbols with an underscore. #ifdef _M_ARM64EC // ARM64EC name mangling for Windows #define ARM64EC_NAME_DECORATION_SYMBOL() # #define ARM64EC_NAME_DECORATE(FuncName) ARM64EC_NAME_DECORATION_SYMBOL() ## FuncName #define PLATFORM_NAME_MANGLE(FuncName) |ARM64EC_NAME_DECORATE(FuncName)| #else #if defined(__APPLE__) // macOS/Mach-O requires underscore prefix for C symbols #define PLATFORM_NAME_MANGLE(FuncName) _ ## FuncName #else // No prefix for other platforms #define PLATFORM_NAME_MANGLE(FuncName) FuncName #endif #endif #if defined(SYMCRYPT_MASM) #if defined(SYMCRYPT_CPU_AMD64) include ksamd64.inc #elif defined(SYMCRYPT_CPU_ARM64) #include "ksarm64.h" #endif #define FILE_END() END #define ALIGN(__alignment) align __alignment #define HEX(__constant) __constant##h #define TEXTAREA() TEXTAREA #define EXTERN(__label) EXTERN __label #define LABEL(__labelname) __labelname #define GET_SYMBOL_ADDRESS(__symbol) __symbol #elif defined(SYMCRYPT_GAS) #if defined(SYMCRYPT_CPU_AMD64) .intel_syntax noprefix #endif #define FILE_END() #define ALIGN(__alignment) .align __alignment #define HEX(__constant) 0x##__constant #define TEXTAREA() #define EXTERN(__label) .extern __label #define LABEL(__labelname) __labelname: #if defined(__APPLE__) #define GET_SYMBOL_ADDRESS(__symbol) _ ## __symbol #else #define GET_SYMBOL_ADDRESS(__symbol) __symbol@plt+rip #endif #else #error Unknown target assembly #endif