[lld] r315139 - Clarify code by adding a comment.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 17:58:19 PDT 2017
Author: ruiu
Date: Fri Oct 6 17:58:19 2017
New Revision: 315139
URL: http://llvm.org/viewvc/llvm-project?rev=315139&view=rev
Log:
Clarify code by adding a comment.
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=315139&r1=315138&r2=315139&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Oct 6 17:58:19 2017
@@ -94,7 +94,13 @@ void OutputSection::addSection(InputSect
return;
}
- if (Live) {
+ if (!Live) {
+ // If IS is the first section to be added to this section,
+ // initialize Type by IS->Type.
+ Live = true;
+ Type = IS->Type;
+ } else {
+ // Otherwise, check if new type or flags are compatible with existing ones.
if ((Flags & (SHF_ALLOC | SHF_TLS)) != (IS->Flags & (SHF_ALLOC | SHF_TLS)))
error("incompatible section flags for " + Name + "\n>>> " + toString(IS) +
": 0x" + utohexstr(IS->Flags) + "\n>>> output section " + Name +
@@ -109,11 +115,8 @@ void OutputSection::addSection(InputSect
getELFSectionTypeName(Config->EMachine, Type));
Type = SHT_PROGBITS;
}
- } else {
- Type = IS->Type;
}
- Live = true;
IS->Parent = this;
Flags |= IS->Flags;
this->updateAlignment(IS->Alignment);
More information about the llvm-commits
mailing list