[lld] r259249 - Add comments.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 14:18:56 PST 2016


Author: ruiu
Date: Fri Jan 29 16:18:55 2016
New Revision: 259249

URL: http://llvm.org/viewvc/llvm-project?rev=259249&view=rev
Log:
Add comments.

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259249&r1=259248&r2=259249&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Jan 29 16:18:55 2016
@@ -1287,6 +1287,7 @@ void MergeOutputSection<ELFT>::addSectio
   StringRef Data((const char *)D.data(), D.size());
   uintX_t EntSize = S->getSectionHdr()->sh_entsize;
 
+  // If this is of type string, the contents are null-terminated strings.
   if (this->Header.sh_flags & SHF_STRINGS) {
     uintX_t Offset = 0;
     while (!Data.empty()) {
@@ -1302,12 +1303,14 @@ void MergeOutputSection<ELFT>::addSectio
       Data = Data.substr(Size);
       Offset += Size;
     }
-  } else {
-    for (unsigned I = 0, N = Data.size(); I != N; I += EntSize) {
-      StringRef Entry = Data.substr(I, EntSize);
-      size_t OutputOffset = Builder.add(Entry);
-      S->Offsets.push_back(std::make_pair(I, OutputOffset));
-    }
+    return;
+  }
+
+  // If this is not of type string, every entry has the same size.
+  for (unsigned I = 0, N = Data.size(); I != N; I += EntSize) {
+    StringRef Entry = Data.substr(I, EntSize);
+    size_t OutputOffset = Builder.add(Entry);
+    S->Offsets.push_back(std::make_pair(I, OutputOffset));
   }
 }
 




More information about the llvm-commits mailing list