From c8e0f79b904548a59a7e0b378671e2d70f624055 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 7 Oct 2017 00:58:19 +0000 Subject: [PATCH] Clarify code by adding a comment. llvm-svn: 315139 --- lld/ELF/OutputSections.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 77b151ea6311..7fe772ad1874 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -94,7 +94,13 @@ void OutputSection::addSection(InputSection *IS) { 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(InputSection *IS) { getELFSectionTypeName(Config->EMachine, Type)); Type = SHT_PROGBITS; } - } else { - Type = IS->Type; } - Live = true; IS->Parent = this; Flags |= IS->Flags; this->updateAlignment(IS->Alignment);