[lld] 2e2d530 - [ELF] Move combineEhSections from Writer to SyntheticSections. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 00:47:34 PDT 2022


Author: Fangrui Song
Date: 2022-07-29T00:47:30-07:00
New Revision: 2e2d5304f0e36083e173995df160bce3c6287a22

URL: https://github.com/llvm/llvm-project/commit/2e2d5304f0e36083e173995df160bce3c6287a22
DIFF: https://github.com/llvm/llvm-project/commit/2e2d5304f0e36083e173995df160bce3c6287a22.diff

LOG: [ELF] Move combineEhSections from Writer to SyntheticSections. NFC

This not only places the function in the right place, but also allows inlining addSection.

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp
    lld/ELF/SyntheticSections.h
    lld/ELF/Writer.cpp
    lld/ELF/Writer.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 919afc7a6e0e..2d96bc6351a8 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3362,6 +3362,27 @@ template <class ELFT> void elf::splitSections() {
   });
 }
 
+void elf::combineEhSections() {
+  llvm::TimeTraceScope timeScope("Combine EH sections");
+  for (InputSectionBase *&s : inputSections) {
+    // Ignore dead sections and the partition end marker (.part.end),
+    // whose partition number is out of bounds.
+    if (!s->isLive() || s->partition == 255)
+      continue;
+
+    Partition &part = s->getPartition();
+    if (auto *es = dyn_cast<EhInputSection>(s)) {
+      part.ehFrame->addSection(es);
+    } else if (s->kind() == SectionBase::Regular && part.armExidx &&
+               part.armExidx->addSection(cast<InputSection>(s))) {
+      s = nullptr;
+    }
+  }
+
+  if (mainPart->armExidx)
+    llvm::erase_value(inputSections, nullptr);
+}
+
 MipsRldMapSection::MipsRldMapSection()
     : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, config->wordsize,
                        ".rld_map") {}

diff  --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 9e95d3f3f65a..2ac89d51e387 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -1202,6 +1202,7 @@ class MemtagAndroidNote : public SyntheticSection {
 InputSection *createInterpSection();
 MergeInputSection *createCommentSection();
 template <class ELFT> void splitSections();
+void combineEhSections();
 
 template <typename ELFT> void writeEhdr(uint8_t *buf, Partition &part);
 template <typename ELFT> void writePhdrs(uint8_t *buf, Partition &part);

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 814eac07b24a..375aa684b798 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -141,27 +141,6 @@ void elf::copySectionsIntoPartitions() {
                        newSections.end());
 }
 
-void elf::combineEhSections() {
-  llvm::TimeTraceScope timeScope("Combine EH sections");
-  for (InputSectionBase *&s : inputSections) {
-    // Ignore dead sections and the partition end marker (.part.end),
-    // whose partition number is out of bounds.
-    if (!s->isLive() || s->partition == 255)
-      continue;
-
-    Partition &part = s->getPartition();
-    if (auto *es = dyn_cast<EhInputSection>(s)) {
-      part.ehFrame->addSection(es);
-    } else if (s->kind() == SectionBase::Regular && part.armExidx &&
-               part.armExidx->addSection(cast<InputSection>(s))) {
-      s = nullptr;
-    }
-  }
-
-  if (mainPart->armExidx)
-    llvm::erase_value(inputSections, nullptr);
-}
-
 static Defined *addOptionalRegular(StringRef name, SectionBase *sec,
                                    uint64_t val, uint8_t stOther = STV_HIDDEN) {
   Symbol *s = symtab->find(name);

diff  --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index 3e7b7d611673..c79be8b0db24 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -19,7 +19,6 @@ class InputFile;
 class OutputSection;
 void copySectionsIntoPartitions();
 template <class ELFT> void createSyntheticSections();
-void combineEhSections();
 template <class ELFT> void writeResult();
 
 // This describes a program header entry.


        


More information about the llvm-commits mailing list