<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 21, 2015 at 7:49 AM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: shankare<br>
Date: Sat Feb 21 09:49:34 2015<br>
New Revision: 230138<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230138&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230138&view=rev</a><br>
Log:<br>
[ELF][Writer] Use Path to create AtomSection.<br>
<br>
Now since the correct file path for atoms is available and not clobbered,<br>
commit r222309 which was reverted previously can be added back.<br>
<br>
No change in functionality.<br></blockquote><div><br></div><div>Why do we need this new code if it doesn't change anything?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h<br>
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h<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=230138&r1=230137&r2=230138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=230138&r1=230137&r2=230138&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Sat Feb 21 09:49:34 2015<br>
@@ -91,24 +91,26 @@ public:<br>
   // The sections are created using<br>
   // SectionName, contentPermissions<br>
   struct SectionKey {<br>
-    SectionKey(StringRef name, DefinedAtom::ContentPermissions perm)<br>
-        : _name(name), _perm(perm) {<br>
-    }<br>
+    SectionKey(StringRef name, DefinedAtom::ContentPermissions perm,<br>
+               StringRef path)<br>
+        : _name(name), _perm(perm), _path(path) {}<br>
<br>
     // Data members<br>
     StringRef _name;<br>
     DefinedAtom::ContentPermissions _perm;<br>
+    StringRef _path;<br>
   };<br>
<br>
   struct SectionKeyHash {<br>
     int64_t operator()(const SectionKey &k) const {<br>
-      return llvm::hash_combine(k._name, k._perm);<br>
+      return llvm::hash_combine(k._name, k._perm, k._path);<br>
     }<br>
   };<br>
<br>
   struct SectionKeyEq {<br>
     bool operator()(const SectionKey &lhs, const SectionKey &rhs) const {<br>
-      return ((lhs._name == rhs._name) && (lhs._perm == rhs._perm));<br>
+      return ((lhs._name == rhs._name) && (lhs._perm == rhs._perm) &&<br>
+              (lhs._path == rhs._path));<br>
     }<br>
   };<br>
<br>
@@ -181,9 +183,10 @@ public:<br>
   virtual StringRef getOutputSectionName(StringRef inputSectionName) const;<br>
<br>
   /// \brief Gets or creates a section.<br>
-  AtomSection<ELFT> *getSection(<br>
-      StringRef name, int32_t contentType,<br>
-      DefinedAtom::ContentPermissions contentPermissions);<br>
+  AtomSection<ELFT> *<br>
+  getSection(StringRef name, int32_t contentType,<br>
+             DefinedAtom::ContentPermissions contentPermissions,<br>
+             StringRef path);<br>
<br>
   /// \brief Gets the segment for a output section<br>
   virtual Layout::SegmentType getSegmentType(Section<ELFT> *section) const;<br>
@@ -530,22 +533,19 @@ AtomSection<ELFT> *DefaultLayout<ELFT>::<br>
 }<br>
<br>
 template <class ELFT><br>
-AtomSection<ELFT> *DefaultLayout<ELFT>::getSection(<br>
-    StringRef sectionName, int32_t contentType,<br>
-    DefinedAtom::ContentPermissions permissions) {<br>
-  // FIXME: We really need the file path here in the SectionKey, when that<br>
-  // is available, replace the sectionKey that has outputSectionName to the<br>
-  // inputSectionName.<br>
-  StringRef outputSectionName = getOutputSectionName(sectionName);<br>
-  const SectionKey sectionKey(outputSectionName, permissions);<br>
+AtomSection<ELFT> *<br>
+DefaultLayout<ELFT>::getSection(StringRef sectionName, int32_t contentType,<br>
+                                DefinedAtom::ContentPermissions permissions,<br>
+                                StringRef path) {<br>
+  const SectionKey sectionKey(sectionName, permissions, path);<br>
+  SectionOrder sectionOrder =<br>
+      getSectionOrder(sectionName, contentType, permissions);<br>
   auto sec = _sectionMap.find(sectionKey);<br>
   if (sec != _sectionMap.end())<br>
     return sec->second;<br>
-  SectionOrder sectionOrder =<br>
-      getSectionOrder(sectionName, contentType, permissions);<br>
   AtomSection<ELFT> *newSec =<br>
       createSection(sectionName, contentType, permissions, sectionOrder);<br>
-  newSec->setOutputSectionName(outputSectionName);<br>
+  newSec->setOutputSectionName(getOutputSectionName(sectionName));<br>
   newSec->setOrder(sectionOrder);<br>
   _sections.push_back(newSec);<br>
   _sectionMap.insert(std::make_pair(sectionKey, newSec));<br>
@@ -565,8 +565,8 @@ ErrorOr<const lld::AtomLayout &> Default<br>
     const DefinedAtom::ContentType contentType = definedAtom->contentType();<br>
<br>
     StringRef sectionName = getInputSectionName(definedAtom);<br>
-    AtomSection<ELFT> *section =<br>
-        getSection(sectionName, contentType, permissions);<br>
+    AtomSection<ELFT> *section = getSection(<br>
+        sectionName, contentType, permissions, definedAtom->file().path());<br>
<br>
     // Add runtime relocations to the .rela section.<br>
     for (const auto &reloc : *definedAtom) {<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=230138&r1=230137&r2=230138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=230138&r1=230137&r2=230138&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Sat Feb 21 09:49:34 2015<br>
@@ -67,6 +67,17 @@ public:<br>
     return *_gpDispAtom;<br>
   }<br>
<br>
+  /// \brief Return the section order for a input section<br>
+  virtual Layout::SectionOrder getSectionOrder(StringRef name,<br>
+                                               int32_t contentType,<br>
+                                               int32_t contentPermissions) {<br>
+    if ((contentType == DefinedAtom::typeStub) && (name.startswith(".text")))<br>
+      return DefaultLayout<ELFType>::ORDER_TEXT;<br>
+<br>
+    return DefaultLayout<ELFType>::getSectionOrder(name, contentType,<br>
+                                                   contentPermissions);<br>
+  }<br>
+<br>
 private:<br>
   llvm::BumpPtrAllocator _alloc;<br>
   MipsGOTSection<ELFType> *_gotSection;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">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>