This is the mail archive of the
mailing list for the binutils project.
Re: MIPS stubs in Gold
Hi Ian (again),
I finally managed to find way how to proceed. I will add code for second
type of stubs (for now) at the end of .text section. I did similar as it
was done for .plt section.
Now I have another question for you: how can I add symbols at the
beginning of every stub? Again I did similar as in .plt, but all symbols
are showing at the beginning of the first stub.
Thanks in advance,
On 28/06/2011 22:07, Richard Sandiford wrote:
> Ian Lance Taylor <email@example.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.