[RFH] How to teach ld to choose in an intelligent fashion whichoutput sections to use for the ensemble of input sections.

Nick Clifton nickc@redhat.com
Thu Oct 20 10:38:00 GMT 2005


Hi Björn,

> You mentioned the keyword: "optimal placement": I have seen that, when doing 
> linker relaxation for avr one could possibly do better if the linker would 
> try to arrange the sequence of the differend object sections (quite a lot of 
> them when using -ffunction-sections) so that as many as possible jumps/calls 
> end up as short pc-relative insn.
> The present situation is not this bad, but I am convinced that one could do 
> better. This might be good for up to 1% code size. 
> Are there targets for which the linker does this kind of shuffling 
> optimization in the source tree?

In the *source* tree ?  No, none that I know of.  Nor are there any 
targets for which the linker tries to reorganise the order of the input 
sections in order to allow for more relaxation opportunities.  (Sorry).

Probably the best way to achieve this kind of optimisation however is 
not to use the linker, but to use the compiler.  For example GCC's 
-funit-at-a-time and -fwhole-program optimisations ought to be able to 
reorder the code to improve the locality of branches and hence provide 
better opportunities for relaxation.

Cheers
   Nick





More information about the Binutils mailing list