This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gold linker patch to split unlikely text into a separate segment


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]