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 stubs in Gold


Ian Lance Taylor <iant@google.com> writes:
> Aleksandar Simeonov <Aleksandar.Simeonov@RT-RK.com> writes:
>
>> Situation is as follows:
>> Some function calls need special handling depend on flags and relocation
>> type. In that case, some additional stub code is needed. There are two
>> types of stubs. One that goes immediately before function and it only
>> contains loading of function address in some register and second that
>> goes on arbitrary place in .text section (usually at the end) and
>> contains loading of function address in some register and jump to that
>> function. Also, relocations that are related to that function call has
>> to be changed in a way to point to that new code. New relocation has to
>> be added to the stub code to fix function address in it. Additional
>> problem for the first type of stub is that is has to be just before
>> function in .text section (it is only used if function is at the
>> beginning of the .text section).
>>
>> I looked at ARM code, also I looked at implementation of plt, but I
>> didn't manage to find what I needed.
>>
>> Can someone give me some hints or ideas what to do and how to proceed
>> with this? Also, which details can help and which can't (there are quite
>> some code in ARM implementation of Gold :-)).
>
> When scanning relocs you need to figure out what stubs you need.  Then
> you need to generate the stubs.
>
> When you say that a stub needs to go immediately before the function, I
> assume that you will be compiling with -ffunction-sections, or you will
> be generating the stubs in the compiler.

Yeah.  The two kinds of stub that Aleksandar describes are two different
ways of setting the incoming function address ($25) to the right value
when linking PIC code into a non-PIC executable.

The kind of stub that goes before the function is more optimal, and like
you say is designed for cases where libraries have been compiled with
-fPIC and -ffunction-sections.  The other kind of stub is a fallback
that is used for functions that live in the middle of sections,
or for situations where the alignment requirements of a section
make the cost of the simpler stub unacceptably high.

Richard


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