Share via


Linker-Generated Thunking Routines

If no declspecs are used to enable interworking function calls, then the linker will generate a thunking routine to perform any necessary caller-side mode changes from ARM to THUMB or vice versa. The linker will generate a thunking routine for each unique function called from an object that requires the opposite mode.

The linker-generated thunking routines handle only the mode switch for the calling of the function. In order for the required mode switch to occur on the return from the function, the programmer must use the /QRinterwork-return - Enable Interworking flag at compile time.

The following example shows a linker-generated thunking routine generated when switching from ARM to THUMB mode.

0xe59fc000    ldr  r12, [pc]
0xe12fff1c    bx   r12
0x00000000    DCD |destination|

The following example shows the linker-generated thunking routine generated when switching from THUMB to ARM mode.

0xb408        push  {r3}
0x4b02        ldr  r3, [pc, #8]
0x469c        mov r12, r3
0xbc08        pop  {r3}
0x4760        bx   r12
0x0000        pad
0x00000000    DCD |destination|

To avoid generation of thunking routines by the linker, use __declspec(iwcall), __declspec(iw16), or __declspec(iw32) as appropriate.

See Also

Mode Switching | ARM Compiler Flags | Declspecs | iwcall | iw16 | iw32 | /QRinterwork-return - Enable Interworking | /QRarch - Specify Target Architecture

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.