From b371a9f082825a014a90453af9793eed88522e06 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 11 Oct 2018 13:19:17 +0000 Subject: [PATCH] lld: set sh_link and sh_info for .rela.plt sections ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the associated string table and sh_info should reference the "section to which the relocation applies." ELF Tool Chain's elfcopy / strip use this (in part) to control whether or not the relocation entry is copied to the output. LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538 Approved by: re (kib) Obtained from: llvm r344226 (backported for 6.0) --- contrib/llvm/tools/lld/ELF/SyntheticSections.cpp | 10 ++++++---- lib/clang/include/lld/Common/Version.inc | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp index bc787bc5907..14f459816de 100644 --- a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp +++ b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp @@ -1213,11 +1213,13 @@ 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. - Link = InX::DynSymTab ? InX::DynSymTab->getParent()->SectionIndex : 0; + // is the case, just use the index of the regular symbol table section. + getParent()->Link = InX::DynSymTab ? + InX::DynSymTab->getParent()->SectionIndex : + InX::SymTab->getParent()->SectionIndex; - // Set required output section properties. - getParent()->Link = Link; + if (InX::RelaIplt == this || InX::RelaPlt == this) + getParent()->Info = InX::GotPlt->getParent()->SectionIndex; } template diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc index 5e7f5111371..35d34551cc8 100644 --- a/lib/clang/include/lld/Common/Version.inc +++ b/lib/clang/include/lld/Common/Version.inc @@ -7,4 +7,4 @@ #define LLD_REPOSITORY_STRING "FreeBSD" // - -#define LLD_REVISION_STRING "335540-1200004" +#define LLD_REVISION_STRING "335540-1200005"