The linker can inline small functions in place of a branch instruction to that function.
For the linker to be able to do this, the function (without the return instruction) must fit
in the four bytes of the branch instruction.
Use the --inline
and --no_inline
command-line options to control branch
inlining. However, --no_inline
only turns off inlining for user-supplied objects. The linker still inlines functions from
the Arm® standard
libraries by default.
If branch inlining optimization is enabled, the linker scans each function call in the
image and then inlines as appropriate. When the linker finds a suitable function to inline,
it replaces the function call with the instruction from the function that is being
called.
The linker applies branch inlining optimization before any unused sections are eliminated
so that inlined sections can also be removed if they are no longer called.
Note:
- For Armv7‑A, the linker can inline two 16-bit encoded Thumb® instructions in place
of the 32-bit encoded Thumb
BL
instruction.
- For Armv8‑A and Armv8‑M, the linker can inline two 16-bit T32 instructions in place of
the 32-bit T32
BL
instruction.
Use the --info=inline
command-line option to list all the inlined
functions.
Note:
The linker does not inline small functions in AArch64
state.