From 940bd4c7711538bc0c3f8059d7d0c626811ceb3c Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 24 Mar 2022 21:54:20 -0700 Subject: [PATCH] [ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC --- lld/ELF/Writer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 153095e44b01..fa374fd08e43 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -710,13 +710,13 @@ template void Writer::addSectionSymbols() { auto *osd = dyn_cast(cmd); if (!osd) continue; - OutputSection *sec = &osd->osec; - auto i = llvm::find_if(sec->commands, [](SectionCommand *cmd) { + OutputSection &osec = osd->osec; + auto i = llvm::find_if(osec.commands, [](SectionCommand *cmd) { if (auto *isd = dyn_cast(cmd)) return !isd->sections.empty(); return false; }); - if (i == sec->commands.end()) + if (i == osec.commands.end()) continue; InputSectionBase *isec = cast(*i)->sections[0]; @@ -733,9 +733,9 @@ template void Writer::addSectionSymbols() { // Set the symbol to be relative to the output section so that its st_value // equals the output section address. Note, there may be a gap between the // start of the output section and isec. - in.symTab->addSymbol( - makeDefined(isec->file, "", STB_LOCAL, /*stOther=*/0, STT_SECTION, - /*value=*/0, /*size=*/0, isec->getOutputSection())); + in.symTab->addSymbol(makeDefined(isec->file, "", STB_LOCAL, /*stOther=*/0, + STT_SECTION, + /*value=*/0, /*size=*/0, &osec)); } }