This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Gold linker patch to split unlikely text into a separate segment
- From: "Sriraman Tallam via binutils" <binutils at sourceware dot org>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Krzysztof Pszeniczny <kpszeniczny at google dot com>, Chris Kennelly <ckennelly at google dot com>, Xinliang David Li <davidxl at google dot com>, Stephane Eranian <eranian at google dot com>, binutils <binutils at sourceware dot org>
- Date: Thu, 19 Oct 2017 17:58:42 -0700
- Subject: Re: Gold linker patch to split unlikely text into a separate segment
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8HmxCpQrbpw8YTLx6zGhTn5XqEp_TBn5_h7v4wTwSHQsQPg@mail.gmail.com> <CAMe9rOpjtiGPQ=zLB4kFgBfamusoYv1ZGkUgnEqt5N+FmiL1_A@mail.gmail.com> <CAAs8Hmx6-TAV5UVjYKzLL70=E=5xWMCb-g6db3EPa=uzMwxF-g@mail.gmail.com> <CAMe9rOoPkLgh6GX=VfBXsfNnVOaz3wr8QQnEzWnBGni3cqZmsQ@mail.gmail.com> <CAAs8Hmw3g7ULov0C8k+ywP8aMM-8gyRu3Ft9FeurpHSP4PBO5A@mail.gmail.com> <CAAs8Hmwmnk=D=cXUdNQuryRFv2yr8Vgk7B3KvwB8Cu-OpPPvnQ@mail.gmail.com> <CAAs8Hmy7=MRfVGTqFuSmT5ja464uTsJ+LjLUqYehPfNz24GV0A@mail.gmail.com> <CAJimCsHyDU172JMjH7tNqT+F5Gc-vj9CkcSgaUrd70Y7OYko=g@mail.gmail.com> <CAAs8HmxhV08ETQ8UxofLs6P5Jamw3pvTdef23WNVWCvoA-W=aA@mail.gmail.com> <CAJimCsGbxdhPmPBNoYaM5hymcZeBYy0Ev5-6WUUyAvsVzze0hw@mail.gmail.com>
- Reply-to: Sriraman Tallam <tmsriram at google dot com>
On Thu, Oct 19, 2017 at 5:47 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>>> Do you want to call set_is_unique_segment() for .text.unlikely
>>> sections? That sounds wrong to me. If that's the right thing to do,
>>> please explain in a comment.
>>
>> Yes, I want the final binary to be like this:
>>
>> Elf file type is EXEC (Executable file)
>> Entry point 0x400560
>> There are 10 program headers, starting at offset 64
>>
>> Program Headers:
>> Type Offset VirtAddr PhysAddr
>> FileSiz MemSiz Flags Align
>>
>> ....
>>
>> LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
>> 0x0000000000000970 0x0000000000000970 R E 1000
>> LOAD 0x0000000000000970 0x0000000000401970 0x0000000000401970
>> 0x000000000000000b 0x000000000000000b R E 1000
>> LOAD 0x0000000000000de8 0x0000000000402de8 0x0000000000402de8
>> ...
>>
>>
>> Section to Segment mapping:
>> Segment Sections...
>> ...
>> 02 .interp .note.ABI-tag .note.gnu.build-id .dynsym .dynstr
>> .gnu.hash .hash .gnu.version .gnu.version_r .rela.dyn .rela.plt .init
>> .plt .text .fini .rodata .eh_frame .eh_frame_hdr
>> 03 .text.unlikely
>> 04 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
>>
>>
>> One more PT_LOAD segment for .text.unlikely which can only be done
>> with set_is_unique_segment.
>
> Won't that put *each* .text.unlikely section in its own unique
> segment? Don't you want one segment containing all .text.unlikely
> sections?
Yes and that is exactly what this does. The output section here
aggregates all text.unlikely sections. The set_is_unique_segment puts
this output section in a separate PT_LOAD segment.
There are two is_unique_segment methods, one for Output_section and
one for Output_segment, maybe that is why this is confusing. This
patch does not change Output_segment, it only changes Output_section.
>
> I guess I need to study how
> Layout::attach_allocated_section_to_segment() works a little harder.
> Maybe I'm just being misled by the name of the flag.
>
> -cary