[ELF] - Set sh_info and sh_link for .rela.plt sections.
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 11 Oct 2018 08:25:35 +0000 (08:25 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 11 Oct 2018 08:25:35 +0000 (08:25 +0000)
commit3368643f5e4e2b06e639cac75e87500dc198ac71
tree850c61b80f0e9435db30a05fc9def6b362abe1e4
parentd966ce4c9836868345e5820b27fe1361e37e2e08
[ELF] - Set sh_info and sh_link for .rela.plt sections.

This is https://bugs.llvm.org/show_bug.cgi?id=37538,

Currently, LLD may set both sh_link and sh_info for
.rela.plt section to zero when we have only .rela.iplt section part used.

ELF spec (https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html)
says that for SHT_REL and SHT_RELA, sh_link references the associated symbol table
and sh_info the "section to which the relocation applies."

When we set the sh_link field, for the regular case we use the .dynsym index.
For .rela.iplt sections, it is unclear what is the associated symbol table,
because R_*_RELATIVE relocations do not use symbol names and we might have no
.dynsym section at all so this patch uses .symtab section index.

Differential revision: https://reviews.llvm.org/D52830

llvm-svn: 344226
lld/ELF/SyntheticSections.cpp
lld/test/ELF/aarch64-gnu-ifunc.s
lld/test/ELF/dynamic-reloc.s
lld/test/ELF/gnu-ifunc-i386.s
lld/test/ELF/gnu-ifunc.s