Skip to content

Commit

Permalink
lld: set sh_link and sh_info for .rela.plt sections
Browse files Browse the repository at this point in the history
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.

Obtained from:	llvm review D52830
  • Loading branch information
emaste committed Oct 9, 2018
1 parent 4c0cfa4 commit 36131f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
Expand Up @@ -1372,11 +1372,15 @@ 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;

// Set required output section properties.
getParent()->Link = Link;
// 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;

if (InX::RelaIplt == this)
getParent()->Info = InX::Iplt->getParent()->SectionIndex;
else if (InX::RelaPlt == this)
getParent()->Info = InX::Plt->getParent()->SectionIndex;
}

template <class ELFT>
Expand Down
2 changes: 1 addition & 1 deletion lib/clang/include/lld/Common/Version.inc
Expand Up @@ -7,4 +7,4 @@

#define LLD_REPOSITORY_STRING "FreeBSD"
// <Upstream revision at import>-<Local identifier in __FreeBSD_version style>
#define LLD_REVISION_STRING "335540-1200004"
#define LLD_REVISION_STRING "335540-1200005"

0 comments on commit 36131f9

Please sign in to comment.