RFC: Sort input section by list

Arjan van de Ven arjan@linux.intel.com
Tue Aug 26 16:48:00 GMT 2008


Christophe LYON wrote:
> 
>>> What is the real purpose of this feature ?  Ie do you know why it has 
>>> been requested ?  The implication of the example you have given is 
>>> that the user wants to put certain name-mangled functions at the 
>>> start of the .text section, but why ?
>>
>> because it allows the developer to put the commonly used functions at 
>> the start of the file,
>> improving density in the page cache for example, and generally 
>> improving startup time.
>> (less pagefaults and less TLB pressure)
>>
> 
> Why not have a tool dedicated to this kind of optimization?
> For one of our targets, we have developed a post linker tool which 
> reorders functions based on call graph analysis.

cool! is this downloadable somewhere ? ;)
> 
> The compiler driver asks the linker to keep all the relocations in the 
> generated executable, and then calls the optimizer, which parses the ELF 
> file and optionally a "layout file" to reorder code. By default it is 
> used to improve locality (we have a direct mapped cache) based on static 
> analysis, but can take advantage of profiling, or the user can even 
> force the function order.
> 
> If the purpose is really to reorder functions, why should the developer 
> need to deal with sections? (I mean, not all developers master the 
> concept of section, do they?)

this is what -ffunction-sections is for

there are some complications like.. does the linker know what the end of a function is?
With tail packing but without sections.. I kind of fear the answer to be "no" ;(



More information about the Binutils mailing list