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: [Mips}Using DT tags for handling local ifuncs


Jack Carter <Jack.Carter@imgtec.com> writes:
> So, does this mean that following the SGI implementation of GP regions
> for multigot is off the table? We bundled all the GP relative sections
> into the equation with each GP region having parts of each. That is,
> there would be multiple .got, .sbss, .sdata, .litxx sections in the
> final dso/exe, but only one per GP region.
>
> We solved the problem. It was well described in the .dynamic table(s) and 
> straight forward for the dynamic linker and dumpers to decipher. Unfortunately
> it never made it in the ABI documentation.

I don't follow.  Whether we use the SGI implementation or not wouldn't
affect things here.  Whether sections keep their original names or are
merged into .got isn't a question for the dynamic linker (which doesn't
care about sections), so it's independent of whether we use dynamic
relocs or multiple .dynamics to handle secondary GOTs.  The question
instead was how to implement this in the static linker.  As bfd works
now, it would be difficult to express the idea of secondary GOTs having
secondary .lit4 output sections, etc., in the linker script.  So we
would need to fiddle with or ignore the linker script if we want
separate (and perhaps multiple) .lit4 output sections.  That's why I
thought putting everything in .got would be easiest.  (As it stands now,
the single .got output section in the linker script is used for both primary
and secondary GOTs.)

And both the SGI and binutils implementation would describe the result
perfectly well.  The new tag I'm suggesting would allow this to work
with no further changes to the dynamic linker.

As for splitting up .sbss and .sdata: the point is that users are
allowed to assume that sections are concatenated in the order specified
by the linker script, which is usually command-line order.  So for example
an object could be split across several input .sdata sections, a bit like
.init_array is really a single array formed from many input .init_arrays.
We would need to define a new section if we want something that the static
linker is free to reorder.

Thanks,
Richard

> On 01/12/2014 01:28 AM, Richard Sandiford wrote:> "Maciej W. Rozycki"
> <macro@codesourcery.com> writes:
>>>   I'm not sure what to do about sections though -- they are not required in
>>> final ELF binaries and not interpreted by ld.so, but we keep them and
>>> therefore have to decide how to handle them.  We could merge all the
>>> original sections into .got, but that could be confusing to some.  We
>>> could keep original .lit4, .sdata, etc. section names, keeping .got for
>>> the legacy GOT part and choosing a new name for the explicitly relocated
>>> GOT part.  But then the reserved entries wouldn't fit anywhere.
>> 
>> Yeah, I was wondering this too.  Things like .lit4 could be handled even
>> in a multigot object, since there's no ODR problem with duplicating the
>> contents in each GOT that needs them (i.e. it's not valid to rely on
>> address equality for .lit4 entries).  So for those I think we could
>> end up with the contents being spread across several GOTs.  And in
>> that case just putting them in .got might be easiest.
>> 
>> Obviously that isn't possible for .sdata and .sbss: we need to keep
>> the original link order.  But in principle we could still put .sdata
>> in a single secondary GOT.
>> 
>> It wouldn't be trivial to do any of this and to make it coexist with
>> linker scripts though.  I'm not sure it's worth spending too much time
>> thinking about it unless someone's actually ready to implement it.
>> 
>> And I'm not sure whether .sdata and .sbss would be much of a win in
>> practice.  It would only help with PIEs and DSOs that make relatively
>> heavy use of a small amount of global state.  How many modern DSOs have
>> that pattern?
>> 
>>>   Also what about .sbss?  Because of the way ELF segments work that must
>>> come last in one or in a separate segment; the alternative is converting
>>> it to all-zero initialised data.
>> 
>> Yeah, it would mean doing the latter.  That comes pretty much for free though:
>> it happens whenever a bss-like section gets stuck behind something else.
>> 
>> Thanks,
>> Richard
>> 


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