C and C++ interworking

The --apcs=/interwork command-line option enables the compiler to compile C and C++ code that can be called from another processor state:

armcc --thumb --apcs=/interwork
armcc --arm --apcs=/interwork

In a leaf function, which is a function whose body contains no function calls, the compiler generates the return instruction BX lr.

In a non-leaf function built for ARMv4T in Thumb state, the compiler must replace, for example, the single return instruction:

     POP  {R4-R7,pc}

with the sequence:

     POP  {R4-R7}	
     POP  {R3}	
     BX   R3

This has a small impact on performance.

The --apcs=/interwork option also sets the interwork attribute for the code area the modules are compiled into. The linker detects this attribute and inserts the appropriate veneers. To find the amount of space taken by the veneers you can use the linker command-line option --info=veneers.

It is recommended that you compile all source modules for interworking, unless you are sure they are never going to be used with interworking.

Note

ARM code compiled for interworking can only be used on ARMv4T and later, because earlier processors do not implement the BX instruction.

Show/hideSee also

Reference
Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0471G
Non-ConfidentialID021412