From ead75fc84f2d55986016099564921bdf9b7f464e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 29 Jan 2016 22:18:55 +0000 Subject: [PATCH] Add comments. llvm-svn: 259249 --- lld/ELF/OutputSections.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index b4e5fad..6022a2a 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1287,6 +1287,7 @@ void MergeOutputSection::addSection(InputSectionBase *C) { 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::addSection(InputSectionBase *C) { 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)); } } -- 2.7.4