[PATCH] D14281: [ELF2] Sort dynamic symbols according to the MIPS requirements.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 10:06:30 PST 2015


The question was more in line of: how does the dynamic linker take
advantage of the got and dynamic symbols being in the same order? Why is
that mips specific?

Also, could the got be sorted to match the symbol table? That way the gnu
hash table would still work. I have asked the same question on the binutils
list where a mips only gnu hash is being discussed.

Cheers, Rafael
On Nov 5, 2015 12:56 PM, "Simon Atanasyan" <simon at atanasyan.com> wrote:

> On Thu, Nov 5, 2015 at 7:55 PM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
> > On 3 November 2015 at 08:34, Igor Kudrin <ikudrin.dev at gmail.com> wrote:
> >>
> >> The MIPS ABI has its requirements to sort entries in the .dyn.sym
> section.
> >> Symbols, which are not in the GOT, have to precede symbols added in the
> GOT.
> >> These latter must have the same order as the corresponding GOT entries.
> >
> > BTW, does anyone know why that restriction exists and why it is still
> relevant?
>
> That would be very funny if nobody knows.
>
> In short, because MIPS ABI is still unchanged and dynamic linkers expect
> to get synchronized GOT and .dyn.sym section.
>
> More wordy, here is a quote from MIPS ABI:
> [[
> The GOT itself is located by the DT_PLTGOT dynamic tag. It is logically
> two tables. The first (with DT_MIPS_LOCAL_GOTNO entries) consists of
> local GOT addresses, i.e. non-preemptible (protected) addresses defined
> within the executable/DSO. They are initialized to their quickstart values,
> and must be relocated if and only if the DSO is loaded at a different
> address
> than that given by its DT_MIPS_BASE_ADDRESS dynamic tag.
>
> The second part of the GOT is the global GOT addresses, i.e. those which
> are undefined or preemptible. Each entry in this part has an associated
> symbol entry in the .dynsym section. Those symbols start at the symbol
> table index given by the DT_MIPS_GOTSYM dynamic tag, and are in the
> same order as the global GOT entries. If a symbol is defined in the DSO
> (but preemptible), the GOT entry will normally be initialized to a
> quickstart
> value.
> ]]
>
> BTW funny fact - DT_PLTGOT points to .got while DT_MIPS_PLTGOT points
> to .got.plt. DT_MIPS_PLTGOT is used for non-PIC code only.
>
> --
> Simon Atanasyan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151105/3c517287/attachment.html>


More information about the llvm-commits mailing list