4.4 C and C++ interworking

The compiler can compile code for interworking on ARMv4T and later.

The --apcs=interwork command-line option enables the compiler to compile C and C++ code that can be called from another instruction set 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.


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

Also, interworking is the default for ARMv5TE and later processors, so you do not have to explicitly specify this.

Non-ConfidentialPDF file icon PDF versionARM DUI0471M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.