What is Windows RT on a standard ARM call call?

I could not find the Windows RT convention documentation on the ARM call used by Visual Studio C ++. Does Microsoft use ARM AAPCS ?

If Microsoft uses AAPCS / EABI for Windows RT in ARM, does it also use ARM C ++ ABI (which is derived from Itanium C ++ ABI)? Perhaps even ARM handling ABI exceptions ?

Is the calling convention used by Windows RT in ARM used from that used by other (built-in) variants of ARM Windows?

Is there a reliable way to detect Windows RT on ARM through predefined compiler macros?

Update: Added question about C ++ ABI.

+4
source share
2 answers

Unlike Windows CE (which uses the original APCS , as well as Old ABI), Windows RT on ARM uses EABI. More specifically, an option that uses floating point registers to transmit floating point data and 8-byte stack / argument alignment.

If I take the following function:

int g(float x) { return x; } 

and compile it using the VS2012 ARM compiler, I get the following assembly:

 |g| PROC vcvt.s32.f32 s0,s0 vmov r0,s0 bx lr ENDP ; |g| 

You can see that it uses S0 , not R0 for the argument.

One of VS2008 (which can be used to install on older versions of Windows CE) calls the following:

 str lr, [sp,#-4]! ldr r3, =__imp___stoi ldr r3, [r3] mov lr, pc bx r3 ldr pc, [sp],#4 

This code calls a helper function to perform the conversion.

The Windows CE compiler shipped with Windows Compact 7 supports both the old calling convention (called "cdecl" from MS) and EABI. See What's New in Platform Builder 7 .

EDIT : Now you notice that you added a question about C ++. Microsoft does not use Itanium-style C ++ ABI, as their implementation precedes this. You can read about the Microsoft implementation in my OpenRCE articles ( 1 , 2 ) and follow the -up Recon presentation . See Also Original Description by Designer Ian Gray: PDF .

+8
source

I can only answer question 2 nd .

Is the calling convention used by Windows RT in ARM used from that used by other (built-in) variants of ARM Windows?

There are three concepts that should be understood. One is the ARM Procedure Call Standard, the other is ABI, and the third is a system call agreement. In short, the ARM procedure call standard describes the use of registers in prolog / epilogue. The ABI language describes how language variables are passed. That is, double , long long , this pointer, dynamic_cast<> , etc. The first is necessary for the assembler interface with the compiler, 2 nd is needed for interaction with the compiler. 3 rd is how OS calls are made.

ARM Procedure Call Standard

The apcs.txt document helps you understand some ARM options. There are 16 options based on four different options.

  • 32-bit and 26-bit PCs - the entire version after 2000 will use the 32-bit version.
  • stack limit check - perhaps reformulated as MMU or MMU.
  • floating point - supported on most processors after about 2005.
  • Re-entrant vs non-re-entrant - choice of clean software; shared libraries?

So, although there are 16 theoretical options, there are only two of them for modern systems using MMUs. The Debian ARM hard float wiki provides information on what some Linux / gcc distributions did. I would suggest that Window RT uses hard float because they don't want to pay a price for performance to support legacy hardware. Finally, it is difficult to think that a shared library or DLL support will not be present in the RT window. So the ARM call handling standard seems to be identical to ABI Linux's tough plan.

'C / C ++' ABI

AAPCS defines how languages ​​are designed to map high-level functions / methods to low-level parts. Manipulating the name ensures that the characters have canonical names so that the tool can be cross-referenced. AAPCS should theoretically interact, but problems may arise with support libraries and other system-level interfaces.

OABI / EABI

The Embedded ARM wiki gives some information about this standard. OS using MMU will use some calls to switch from user mode to system mode. As a rule, these are only library functions and are not part of the compiler. However, you may find some ARM systems that use the OABI convention . Since Microsoft is running late with the ARM game, they will either use EABI or come up with something new. For example, calling malloc() with the gcc linux hard-float compiler will not work, since the system calls will be completely different. Typically, you will have to compile -nostdlib and come up with your own C library.

I was looking a bit for search information in Visual C ++.

So, to answer your 2 nd question, there are many compilers / systems that will generate a similar prolog / epilogue. If Visual C ++ uses AAPCS , it can interact with other AAPCS compilers. You may need to create your own libraries to force another compiler to call Windows RT system calls. Other questions should be given in the manual.

Edit: GCC ARM -mabi selects ABI . aapcs-linux is AAPCS / EABI, apcs-gnu is OABI, which defines the prolog / epilogue and argument mapping. The compiler configuration selects the target OS and the type of command / back -end / CPU; therefore, we have compilers with different names, for example arm-linux-eabi-gcc , arm-linux-gnueabi-gcc`, etc.

+3
source

Source: https://habr.com/ru/post/1479141/


All Articles