4.3.3. Pointers to functions in Thumb state

If you have a Thumb function, that is a function consisting of Thumb code, and that runs in Thumb state, then any pointer to that function must have the least significant bit set. This ensures that interworking works correctly.

When the linker relocates a value of a label referring to a Thumb instruction, it automatically sets the least significant bit of the relocated value. The linker cannot do this if you use absolute addresses to Thumb functions.

Therefore, if you have to use an absolute address to a Thumb function in your code, you must add one to the address. For example, you might have a table of pointers to Thumb functions, such as that shown in Example 4.5.

See Assembly language interworking for more details.

Example 4.5. Absolute addresses to Thumb functions

typedef int (*FN)();

myfunc() {
    FN fnptrs[] = {
        (FN)(0x8084 + 1),  // Valid Thumb address
        (FN)(0x8074)       // Invalid Thumb address
    };
    FN* myfunctions = fnptrs;

    myfunctions[0]();    // Call OK
    myfunctions[1]();    // Call Fails
}
Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential