<div dir="ltr">Hi Rui,<div><br></div><div>No problem, thanks for reverting this. This memory bug didn't manifest when compiling in optimized builds and that's why I missed it, but it does when compiling in debug mode and I was able to reproduce it now. I'm currently analyzing this and it looks like a memory bug due to an ELFUndefinedSymbol being created with an uninitialized ELF_Sym.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 9:16 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Rafael,<div><br></div><div>This seems to break buildbots: <a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-debian-fast/builds/18758" target="_blank">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-debian-fast/builds/18758</a>. These tests are failing on my machine too.</div><div><br></div><div>I rolled back this in <span style="color:rgb(0,0,0)">r219369. Sorry for your inconvenience.</span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 3:53 PM, Rafael Auler <span dir="ltr"><<a href="mailto:rafaelauler@gmail.com" target="_blank">rafaelauler@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafauler<br>
Date: Wed Oct 8 17:53:49 2014<br>
New Revision: 219353<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=219353&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=219353&view=rev</a><br>
Log:<br>
[ELF] Only mark as DT_NEEDED libs that are strictly necessary<br>
<br>
Enhances the creation of an ELF dynamic executable by avoiding recording<br>
unnecessary shared libraries as NEEDED to load a program.<br>
<br>
To do this, we must keep track of not only symbols that were referenced but<br>
also of COPY relocations, which steal the symbol from a shared library but does<br>
not store from which lib this symbol came from. To fix this, this commit changes<br>
ObjectSymbol to store the original library from which this symbol came. With<br>
this information, we are able to build a list of the exact shared libraries that<br>
must be marked as DT_NEEDED, instead of blindly marking all shared libraries as<br>
needed.<br>
<br>
This logic originally came from the MIPS backend with some adaptation.<br>
<br>
Reviewers: atanasyan, shankar.easwaran<br>
<br>
<a href="http://reviews.llvm.org/D5574" target="_blank">http://reviews.llvm.org/D5574</a><br>
<br>
Modified:<br>
  lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
  lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h<br>
  lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp<br>
  lld/trunk/lib/ReaderWriter/ELF/Atoms.h<br>
  lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp<br>
  lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h<br>
  lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h<br>
  lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h<br>
  lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Oct 8 17:53:49 2014<br>
@@ -90,6 +90,15 @@ public:<br>
                  const Reference &) const {<br>
   return false;<br>
  }<br>
+<br>
+Â /// \brief Is this a copy relocation?<br>
+Â ///<br>
+Â /// If this is a copy relocation, its target must be an ObjectAtom. We must<br>
+Â /// include in DT_NEEDED the name of the library where this object came from.<br>
+Â virtual bool isCopyRelocation(const Reference &) const {<br>
+Â Â return false;<br>
+Â }<br>
+<br>
  bool validateImpl(raw_ostream &diagnostics) override;<br>
<br>
  /// \brief Does the linker allow dynamic libraries to be linked with?<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h Wed Oct 8 17:53:49 2014<br>
@@ -59,6 +59,15 @@ public:<br>
   }<br>
  }<br>
<br>
+Â bool isCopyRelocation(const Reference &r) const override {<br>
+Â Â if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
+Â Â Â return false;<br>
+Â Â assert(r.kindArch() == Reference::KindArch::AArch64);<br>
+Â Â if (r.kindValue() == llvm::ELF::R_AARCH64_COPY)<br>
+Â Â Â return true;<br>
+Â Â return false;<br>
+Â }<br>
+<br>
  bool isPLTRelocation(const DefinedAtom &,<br>
                const Reference &r) const override {<br>
   if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp Wed Oct 8 17:53:49 2014<br>
@@ -452,7 +452,7 @@ public:<br>
   if (obj != _objectMap.end())<br>
    return obj->second;<br>
<br>
-Â Â auto oa = new (_file._alloc) ObjectAtom(_file);<br>
+Â Â auto oa = new (_file._alloc) ObjectAtom(_file, a);<br>
   // This needs to point to the atom that we just created.<br>
   oa->addReferenceELF_AArch64(R_AARCH64_COPY, 0, oa, 0);<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Wed Oct 8 17:53:49 2014<br>
@@ -689,8 +689,11 @@ public:<br>
 /// \brief Atom which represents an object for which a COPY relocation will be<br>
 ///  generated.<br>
 class ObjectAtom : public SimpleELFDefinedAtom {<br>
+Â const SharedLibraryAtom *_sla;<br>
+<br>
 public:<br>
-Â ObjectAtom(const File &f) : SimpleELFDefinedAtom(f) {}<br>
+Â ObjectAtom(const File &f, const SharedLibraryAtom *sla)<br>
+Â Â Â : SimpleELFDefinedAtom(f), _sla(sla) {}<br>
<br>
  Scope scope() const override { return scopeGlobal; }<br>
<br>
@@ -713,6 +716,8 @@ public:<br>
<br>
  StringRef name() const override { return _name; }<br>
<br>
+Â const SharedLibraryAtom *getOriginalOwner() const { return _sla; }<br>
+<br>
  std::string _name;<br>
  uint64_t _size;<br>
 };<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Wed Oct 8 17:53:49 2014<br>
@@ -10,6 +10,7 @@<br>
 #ifndef LLD_READER_WRITER_ELF_DEFAULT_LAYOUT_H<br>
 #define LLD_READER_WRITER_ELF_DEFAULT_LAYOUT_H<br>
<br>
+#include "Atoms.h"<br>
 #include "Chunk.h"<br>
 #include "HeaderChunks.h"<br>
 #include "Layout.h"<br>
@@ -171,6 +172,7 @@ public:<br>
  typedef typename std::vector<lld::AtomLayout *>::iterator AbsoluteAtomIterT;<br>
<br>
  typedef llvm::DenseSet<const Atom *> AtomSetT;<br>
+Â typedef llvm::DenseSet<const SharedLibraryAtom *> SharedLibraryAtomSetT;<br>
<br>
  DefaultLayout(const ELFLinkingContext &context) : _context(context) {}<br>
<br>
@@ -303,6 +305,10 @@ public:<br>
   return _referencedDynAtoms.count(a);<br>
  }<br>
<br>
+Â const SharedLibraryAtomSetT &getCopiedDynAtoms() const {<br>
+Â Â return _copiedDynAtoms;<br>
+Â }<br>
+<br>
 protected:<br>
  /// \brief Allocate a new section.<br>
  virtual AtomSection<ELFT> *createSection(<br>
@@ -325,6 +331,7 @@ protected:<br>
  LLD_UNIQUE_BUMP_PTR(RelocationTable<ELFT>) _pltRelocationTable;<br>
  std::vector<lld::AtomLayout *> _absoluteAtoms;<br>
  AtomSetT _referencedDynAtoms;<br>
+Â SharedLibraryAtomSetT _copiedDynAtoms;<br>
  const ELFLinkingContext &_context;<br>
 };<br>
<br>
@@ -582,7 +589,14 @@ ErrorOr<const lld::AtomLayout &> Default<br>
    if (isa<UndefinedAtom>(reloc->target()) && isLocalReloc)<br>
     continue;<br>
<br>
-Â Â Â _referencedDynAtoms.insert(reloc->target());<br>
+Â Â Â if (!_context.isCopyRelocation(*reloc)) {<br>
+Â Â Â Â _referencedDynAtoms.insert(reloc->target());<br>
+Â Â Â Â continue;<br>
+Â Â Â }<br>
+<br>
+Â Â Â const ObjectAtom *oa = dyn_cast<ObjectAtom>(reloc->target());<br>
+Â Â Â assert (oa != nullptr && "Targets of copy relocs must be ObjectAtoms");<br>
+Â Â Â _copiedDynAtoms.insert(oa->getOriginalOwner());<br>
   }<br>
<br>
   return section->appendAtom(atom);<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h Wed Oct 8 17:53:49 2014<br>
@@ -37,10 +37,6 @@ protected:<br>
   return std::error_code();<br>
  }<br>
<br>
-Â bool isNeededTagRequired(const SharedLibraryAtom *sla) const override {<br>
-Â Â return _writeHelper.isNeededTagRequired(sla);<br>
-Â }<br>
-<br>
  LLD_UNIQUE_BUMP_PTR(DynamicTable<ELFT>) createDynamicTable();<br>
<br>
  LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable<ELFT>) createDynamicSymbolTable();<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h Wed Oct 8 17:53:49 2014<br>
@@ -69,11 +69,6 @@ public:<br>
   return file;<br>
  }<br>
<br>
-Â bool isNeededTagRequired(const SharedLibraryAtom *sla) const {<br>
-Â Â return _targetLayout.isReferencedByDefinedAtom(sla) ||<br>
-Â Â Â Â Â Â _targetLayout.isCopied(sla);<br>
-Â }<br>
-<br>
 private:<br>
  MipsLinkingContext &_ctx;<br>
  MipsTargetLayout<ELFT> &_targetLayout;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h Wed Oct 8 17:53:49 2014<br>
@@ -38,10 +38,6 @@ protected:<br>
   return std::error_code();<br>
  }<br>
<br>
-Â bool isNeededTagRequired(const SharedLibraryAtom *sla) const override {<br>
-Â Â return _writeHelper.isNeededTagRequired(sla);<br>
-Â }<br>
-<br>
  LLD_UNIQUE_BUMP_PTR(DynamicTable<ELFT>) createDynamicTable();<br>
<br>
  LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable<ELFT>) createDynamicSymbolTable();<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp Wed Oct 8 17:53:49 2014<br>
@@ -65,6 +65,15 @@ bool MipsLinkingContext::isDynamicReloca<br>
  }<br>
 }<br>
<br>
+bool MipsLinkingContext::isCopyRelocation(const Reference &r) const {<br>
+Â if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
+Â Â return false;<br>
+Â assert(r.kindArch() == Reference::KindArch::Mips);<br>
+Â if (r.kindValue() == llvm::ELF::R_MIPS_COPY)<br>
+Â Â return true;<br>
+Â return false;<br>
+}<br>
+<br>
 bool MipsLinkingContext::isPLTRelocation(const DefinedAtom &,<br>
                     const Reference &r) const {<br>
  if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h Wed Oct 8 17:53:49 2014<br>
@@ -47,6 +47,7 @@ public:<br>
  bool isRelaOutputFormat() const override { return false; }<br>
  bool isDynamicRelocation(const DefinedAtom &,<br>
              const Reference &r) const override;<br>
+Â bool isCopyRelocation(const Reference &r) const override;<br>
  bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override;<br>
 };<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Wed Oct 8 17:53:49 2014<br>
@@ -781,7 +781,7 @@ RelocationPass<ELFT>::getObjectEntry(con<br>
  if (obj != _objectMap.end())<br>
   return obj->second;<br>
<br>
-Â auto oa = new (_file._alloc) ObjectAtom(_file);<br>
+Â auto oa = new (_file._alloc) ObjectAtom(_file, a);<br>
  oa->addReferenceELF_Mips(R_MIPS_COPY, 0, oa, 0);<br>
  oa->_name = a->name();<br>
  oa->_size = a->size();<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Wed Oct 8 17:53:49 2014<br>
@@ -62,26 +62,6 @@ public:<br>
   }<br>
  }<br>
<br>
-Â ErrorOr<const lld::AtomLayout &> addAtom(const Atom *atom) override {<br>
-Â Â // Maintain:<br>
-Â Â // 1. Set of shared library atoms referenced by regular defined atoms.<br>
-Â Â // 2. Set of shared library atoms have corresponding R_MIPS_COPY copies.<br>
-Â Â if (const auto *da = dyn_cast<DefinedAtom>(atom))<br>
-Â Â Â for (const Reference *ref : *da) {<br>
-Â Â Â Â if (ref->kindNamespace() == lld::Reference::KindNamespace::ELF) {<br>
-Â Â Â Â Â assert(ref->kindArch() == Reference::KindArch::Mips);<br>
-Â Â Â Â Â if (ref->kindValue() == llvm::ELF::R_MIPS_COPY)<br>
-Â Â Â Â Â Â _copiedDynSymNames.insert(atom->name());<br>
-Â Â Â Â }<br>
-Â Â Â }<br>
-<br>
-Â Â return TargetLayout<ELFType>::addAtom(atom);<br>
-Â }<br>
-<br>
-Â bool isCopied(const SharedLibraryAtom *sla) const {<br>
-Â Â return _copiedDynSymNames.count(sla->name());<br>
-Â }<br>
-<br>
  /// \brief GP offset relative to .got section.<br>
  uint64_t getGPOffset() const { return 0x7FF0; }<br>
<br>
@@ -109,7 +89,6 @@ private:<br>
  MipsPLTSection<ELFType> *_pltSection;<br>
  llvm::Optional<AtomLayout *> _gpAtom;<br>
  llvm::Optional<AtomLayout *> _gpDispAtom;<br>
-Â llvm::StringSet<> _copiedDynSymNames;<br>
 };<br>
<br>
 /// \brief Mips Runtime file.<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Wed Oct 8 17:53:49 2014<br>
@@ -180,11 +180,14 @@ template <class ELFT><br>
 void OutputELFWriter<ELFT>::buildDynamicSymbolTable(const File &file) {<br>
  ScopedTask task(getDefaultDomain(), "buildDynamicSymbolTable");<br>
  for (const auto &sla : file.sharedLibrary()) {<br>
-Â Â if (isDynSymEntryRequired(sla))<br>
-Â Â Â _dynamicSymbolTable->addSymbol(sla, ELF::SHN_UNDEF);<br>
+Â Â if (!isDynSymEntryRequired(sla))<br>
+Â Â Â continue;<br>
+Â Â _dynamicSymbolTable->addSymbol(sla, ELF::SHN_UNDEF);<br>
   if (isNeededTagRequired(sla))<br>
    _soNeeded.insert(sla->loadName());<br>
  }<br>
+Â for (const auto &sla : _layout.getCopiedDynAtoms())<br>
+Â Â _soNeeded.insert(sla->loadName());<br>
  // Never mark the dynamic linker as DT_NEEDED<br>
  _soNeeded.erase(sys::path::filename(_context.getInterpreter()));<br>
  for (const auto &loadName : _soNeeded) {<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h Wed Oct 8 17:53:49 2014<br>
@@ -58,6 +58,15 @@ public:<br>
   }<br>
  }<br>
<br>
+Â bool isCopyRelocation(const Reference &r) const override {<br>
+Â Â if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
+Â Â Â return false;<br>
+Â Â assert(r.kindArch() == Reference::KindArch::x86_64);<br>
+Â Â if (r.kindValue() == llvm::ELF::R_X86_64_COPY)<br>
+Â Â Â return true;<br>
+Â Â return false;<br>
+Â }<br>
+<br>
  virtual bool isPLTRelocation(const DefinedAtom &,<br>
                const Reference &r) const override {<br>
   if (r.kindNamespace() != Reference::KindNamespace::ELF)<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=219353&r1=219352&r2=219353&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Wed Oct 8 17:53:49 2014<br>
@@ -430,7 +430,7 @@ public:<br>
   if (obj != _objectMap.end())<br>
    return obj->second;<br>
<br>
-Â Â auto oa = new (_file._alloc) ObjectAtom(_file);<br>
+Â Â auto oa = new (_file._alloc) ObjectAtom(_file, a);<br>
   // This needs to point to the atom that we just created.<br>
   oa->addReferenceELF_x86_64(R_X86_64_COPY, 0, oa, 0);<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>