hot/cold section support

H.J. Lu hjl.tools@gmail.com
Fri Sep 4 18:10:00 GMT 2009


On Fri, Sep 4, 2009 at 10:59 AM, Doug Evans<dje@google.com> wrote:
> On Thu, Sep 3, 2009 at 11:36 PM, Alan Modra<amodra@bigpond.net.au> wrote:
>> This causes ld to group cold text sections together for better cache
>> locality.  I chose to put them before other text sections because this
>> places the cold sections next to .init and a number of targets
>> generate stubs placed at the end of .text.  Also, placing cold
>> sections at the end of .text would require non-trivial changes to
>> section name matching.  (You'd need to be able to say "match .text.*
>> but not .text.*_unlikely".)
>>
>> I'll leave updating other ELF scripts to their respective maintainers.
>>
>>        * scripttempl/elf.sc (.text): Add cold text sections.
>>
>> Index: ld/scripttempl/elf.sc
>> ===================================================================
>> RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
>> retrieving revision 1.94
>> diff -u -p -r1.94 elf.sc
>> --- ld/scripttempl/elf.sc       1 Sep 2009 02:54:10 -0000       1.94
>> +++ ld/scripttempl/elf.sc       3 Sep 2009 15:28:06 -0000
>> @@ -410,6 +410,7 @@ cat <<EOF
>>   .text         ${RELOCATING-0} :
>>   {
>>     ${RELOCATING+${TEXT_START_SYMBOLS}}
>> +    ${RELOCATING+*(.text.unlikely .text.*_unlikely)}
>>     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
>>     /* .gnu.warning sections are handled specially by elf32.em.  */
>>     *(.gnu.warning)
>
> OOC, how about a similar thing for hot sections?
>
> I'm also curious who generates .text.*_unlikely.
>
> P.S. There is an issue that gcc -ffunction-sections and
> __attribute__((hot/cold)) don't play nice together.  Having gcc emit
> hot/cold to .text.{hot,unlikely}.<label> would fix that (along with
> these linker changes).
>

That is

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24201

-- 
H.J.



More information about the Binutils mailing list