[PATCH] D21297: [ELF][MIPS] Support GOT entries for non-preemptible symbols with different addends

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 06:21:43 PDT 2016

So, there something I don't understand about the mips abi. In other
ABIs, a got relocation of symbol foo with addend X means
"got_entry(foo) + X". For example, R_X86_64_GOTPCREL normally has and
addend of -4 since it is commonly used with pc relative addressing
that uses the address of the next instruction.

What exactly is the rule for mips? Is a R_MIPS_SOMETHING_GOT with an
addend of X supposed to mean "got_entry(foo + X)"? Is that always the
case? Only for some relocations? Only when foo is local?


On 13 June 2016 at 12:24, Simon Atanasyan <simon at atanasyan.com> wrote:
> atanasyan created this revision.
> atanasyan added reviewers: ruiu, rafael.
> atanasyan added a subscriber: llvm-commits.
> atanasyan set the repository for this revision to rL LLVM.
> atanasyan added a project: lld.
> Herald added a subscriber: sdardis.
> There are two motivations for this patch. The first one is a preparation for support MIPS TLS relocations. It might sound like a joke but for GOT entries related to TLS relocations MIPS ABI uses almost regular approach with creation of dynamic relocations for each GOT enty etc. But we need to separate these 'regular' TLS related entries from MIPS specific local/global parts of GOT. ABI declare simple solution - all TLS related entries allocated at the end of GOT after local/global parts. The second motivation it to support GOT relocations for non-preemptible symbols with addends. If we have more than one GOT relocations against symbol S with different addends we need to create GOT entries for each unique Symbol/Addend pairs.
> So we store all MIPS GOT entries in separate containers. For non-preemptible symbols we have to maintain two data structures. The first one is `MipsLocal` vector. Each entry corresponds to the GOT entry from the 'local' part of the GOT contains the symbol's address plus addend. The second one is `MipsLocalMap`. It is a map from Symbol/Addend pair to the GOT index.
> Repository:
>   rL LLVM
> http://reviews.llvm.org/D21297
> Files:
>   ELF/InputSection.cpp
>   ELF/OutputSections.cpp
>   ELF/OutputSections.h
>   ELF/Relocations.cpp
>   ELF/Symbols.cpp
>   ELF/Symbols.h
>   test/ELF/mips-64-disp.s
>   test/ELF/mips-64-got.s
>   test/ELF/mips-dynamic.s
>   test/ELF/mips-got16.s
>   test/ELF/mips-plt-copy.s
>   test/ELF/mips-sto-plt.s

More information about the llvm-commits mailing list