[lld] 940bd4c - [ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 21:54:25 PDT 2022


Author: Fangrui Song
Date: 2022-03-24T21:54:20-07:00
New Revision: 940bd4c7711538bc0c3f8059d7d0c626811ceb3c

URL: https://github.com/llvm/llvm-project/commit/940bd4c7711538bc0c3f8059d7d0c626811ceb3c
DIFF: https://github.com/llvm/llvm-project/commit/940bd4c7711538bc0c3f8059d7d0c626811ceb3c.diff

LOG: [ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC

Added: 
    

Modified: 
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 153095e44b01a..fa374fd08e432 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -710,13 +710,13 @@ template <class ELFT> void Writer<ELFT>::addSectionSymbols() {
     auto *osd = dyn_cast<OutputDesc>(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<InputSectionDescription>(cmd))
         return !isd->sections.empty();
       return false;
     });
-    if (i == sec->commands.end())
+    if (i == osec.commands.end())
       continue;
     InputSectionBase *isec = cast<InputSectionDescription>(*i)->sections[0];
 
@@ -733,9 +733,9 @@ template <class ELFT> void Writer<ELFT>::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));
   }
 }
 


        


More information about the llvm-commits mailing list