|Non-Confidential||PDF version||ARM DUI0471M|
|Home > Interworking ARM and Thumb > About interworking|
Interworking enables you to mix ARM and Thumb code.
This means that:
ARM routines can return to a Thumb state caller
Thumb routines can return to an ARM state caller.
This has the benefit 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
compiler and 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.
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 instruction set state where necessary.
The ARM architecture v5T and later provide methods to change instruction set 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