| |||
| Home > Interworking ARM and Thumb > About interworking | |||
Interworking enables you to mix ARM and Thumb code so that:
ARM routines return to a Thumb state caller
Thumb routines return to an ARM state caller.
This means that, if you compile or assemble code for interworking,
your code can call a routine in a different module without considering
which instruction set it uses. The ARM compiler and ARM assembler
both use the --apcs=/interwork command-line option
to enable interworking.
You can freely mix code compiled or assembled for ARM and
Thumb, provided that the code conforms to the AAPCS. See the specification,
in .install_directory\Documentation\Specifications\...\PDF\aapcs.pdf
An error is generated if the linker detects:
a direct ARM or Thumb interworking call where the callee routine is not built for interworking
assembly language source files using incompatible AAPCS options.
The ARM linker detects when an interworking function is being called from a different state. Call and return instructions are changed, and small code segments called veneers, are inserted to change processor state where necessary. See Veneers in the Linker User Guide for more information.
The ARM architecture v5T and later provide methods to change processor state without using any extra instructions. There is almost no cost associated with interworking on ARMv5T and later processors.
Compiling for ARMv5T and later architectures, automatically
assumes interworking and always produces code that is interworking
safe. However, assembly code built for ARMv5T does not imply interworking,
so you must build assembly code with the --apcs=/interwork assembler
option.