[ELF][MIPS] Create GOT entries for R_MIPS_REL32 dynamic relocations
authorSimon Atanasyan <simon@atanasyan.com>
Wed, 20 Apr 2016 21:40:33 +0000 (21:40 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Wed, 20 Apr 2016 21:40:33 +0000 (21:40 +0000)
commitca58a8ff5ba77a2018e8e80014cfe7a71b746b37
tree325a572997d47fbac9d9d60de21f4c5f7b667d21
parentdd98c91e08318e50c3fb08cc3196dd6cfa1c3c92
[ELF][MIPS] Create GOT entries for R_MIPS_REL32 dynamic relocations

MIPS ABI turns using of GOT and dynamic relocations inside out. While
regular ABI uses dynamic relocations to fill up GOT entries MIPS ABI
requires dynamic linker to fills up GOT entries using specially sorted
dynamic symbol table. This affects even dynamic relocations against
symbols which do not require GOT entries creation explicitly, i.e. do
not have any GOT-relocations. So if a preemptible symbol has a dynamic
relocation we anyway have to create a GOT entry for it.

If a non-preemptible symbol has a dynamic relocation against it, dynamic
linker takes it st_value, adds offset and writes down result of the
dynamic relocation. In case of preemptible symbol dynamic linker
performs symbol resolution, writes the symbol value to the GOT entry and
reads the GOT entry when it needs to perform a dynamic relocation.

Differential Revision: http://reviews.llvm.org/D18948

llvm-svn: 266921
lld/ELF/Writer.cpp
lld/test/ELF/mips-32.s