summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-10-11 08:25:35 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-10-11 08:25:35 +0000
commit3368643f5e4e2b06e639cac75e87500dc198ac71 (patch)
tree850c61b80f0e9435db30a05fc9def6b362abe1e4 /lld/ELF/SyntheticSections.cpp
parentd966ce4c9836868345e5820b27fe1361e37e2e08 (diff)
downloadbcm5719-llvm-3368643f5e4e2b06e639cac75e87500dc198ac71.tar.gz
bcm5719-llvm-3368643f5e4e2b06e639cac75e87500dc198ac71.zip
[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
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index bc398fed17c..e32b8c29fc1 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1493,9 +1493,12 @@ void RelocationBaseSection::addReloc(const DynamicReloc &Reloc) {
void RelocationBaseSection::finalizeContents() {
// If all relocations are R_*_RELATIVE they don't refer to any
// dynamic symbol and we don't need a dynamic symbol table. If that
- // is the case, just use 0 as the link.
- getParent()->Link =
- In.DynSymTab ? In.DynSymTab->getParent()->SectionIndex : 0;
+ // is the case, just use the index of the regular symbol table section.
+ getParent()->Link = In.DynSymTab ? In.DynSymTab->getParent()->SectionIndex
+ : In.SymTab->getParent()->SectionIndex;
+
+ if (In.RelaIplt == this || In.RelaPlt == this)
+ getParent()->Info = In.GotPlt->getParent()->SectionIndex;
}
RelrBaseSection::RelrBaseSection()
OpenPOWER on IntegriCloud