5.7.1.12 Long-calls Option

The -mlong-calls option tells the compiler to perform function calls by first loading the address of the function into a register and then performing a subroutine call on this register. This switch is needed if the target function lies outside of the addressing range of the offset-based version of subroutine call instruction. This range various with device and ISA. It is typically required when calling a function in another memory region. For instance, when calling a ram-allocated function from a flash-allocated function, the target address may be out of range of a short call.

Even if this feature is enabled, not all function calls are turned into long calls. The heuristic is that static functions, functions that have the short_call attribute, functions that are inside the scope of a #pragma no_long_calls directive, and functions whose definitions have already been compiled within the current compilation unit are not turned into long calls. The exceptions to this rule are that weak function definitions, functions with the long_call attribute or the section attribute, and functions that are within the scope of a #pragma long_calls directive are always turned into long calls. This feature does not affect how the compiler generates code to indirectly call functions via a pointer.

The -mno-long-calls form of this option will not use long calls. This is the default action if no option is specified.