4 ms·
> The problem is, depending on where exactly the called function ends up, the function call might be more or fewer instructions long. That means, depending on w
by glandium 4y ago
> The problem is, depending on where exactly the called function ends up, the function call might be more or fewer instructions long. That means, depending on what exact kind of call sequence is required, all the other code in the function has to be shifted around, since all jump targets shift around.
Linkers actually don't change instruction lengths. If they need to jump further away than what the instruction allows, they add trampolines, which are chunks of code with the appropriate instruction for the long jump, and place the trampoline at a good distance of the relocatable short jump.
Edit: well, except in the proposed case of relaxation, where they'd want to shorten jump instructions.