[lld] r195595 - [PECOFF] Change sectionChoice attribute.

Rui Ueyama ruiu at google.com
Sun Nov 24 20:12:24 PST 2013


Author: ruiu
Date: Sun Nov 24 22:12:24 2013
New Revision: 195595

URL: http://llvm.org/viewvc/llvm-project?rev=195595&view=rev
Log:
[PECOFF] Change sectionChoice attribute.

Change the attribute from sectionBasedOnContent to sectionCustomRequired
because its the right attribute for atoms read from COFF files to have.
COFF atoms should basically be emitted to the section having the same name
as input. Permissions/attributes should not affect that.

There's no functionality change because the writer doesn't yet use the
section name. The writer will be modified in a following patch, so that atoms
are written to its customSectionName()'s section.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
    lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h?rev=195595&r1=195594&r2=195595&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h Sun Nov 24 22:12:24 2013
@@ -101,8 +101,8 @@ public:
   virtual Interposable interposable() const { return interposeNo; }
   virtual Merge merge() const { return mergeNo; }
   virtual Alignment alignment() const { return Alignment(0); }
-  virtual SectionChoice sectionChoice() const { return sectionBasedOnContent; }
-  virtual StringRef customSectionName() const { return ""; }
+  virtual SectionChoice sectionChoice() const = 0;
+  virtual StringRef customSectionName() const { return ""; };
   virtual SectionPosition sectionPosition() const { return sectionPositionAny; }
   virtual DeadStripKind deadStrip() const { return deadStripNormal; }
   virtual bool isAlias() const { return false; }
@@ -160,7 +160,8 @@ public:
 
   void setAlignment(Alignment val) { _alignment = val; };
 
-  virtual StringRef getSectionName() const { return _sectionName; }
+  virtual SectionChoice sectionChoice() const { return sectionCustomRequired; }
+  virtual StringRef customSectionName() const { return _sectionName; };
   virtual Scope scope() const { return _scope; }
   virtual ContentType contentType() const { return _contentType; }
   virtual ContentPermissions permissions() const { return _permissions; }
@@ -227,6 +228,7 @@ private:
 /// not read from file.
 class COFFLinkerInternalAtom : public COFFBaseDefinedAtom {
 public:
+  virtual SectionChoice sectionChoice() const { return sectionBasedOnContent; }
   virtual uint64_t ordinal() const { return 0; }
   virtual Scope scope() const { return scopeGlobal; }
   virtual Alignment alignment() const { return Alignment(0); }

Modified: lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h?rev=195595&r1=195594&r2=195595&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h Sun Nov 24 22:12:24 2013
@@ -78,7 +78,7 @@ private:
     for (const DefinedAtom *atom : mutableFile.defined()) {
       auto *coffAtom = dyn_cast<COFFDefinedAtom>((COFFBaseDefinedAtom *)atom);
       if (coffAtom && coffAtom->ordinal() == 0)
-        result[coffAtom->getSectionName()].push_back(coffAtom);
+        result[coffAtom->customSectionName()].push_back(coffAtom);
     }
     return result;
   }

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=195595&r1=195594&r2=195595&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Sun Nov 24 22:12:24 2013
@@ -699,7 +699,6 @@ void SectionChunk::buildContents(const F
                                  bool (*isEligible)(const DefinedAtom *)) {
   // Extract atoms from the linked file and append them to this section.
   for (const DefinedAtom *atom : linkedFile.defined()) {
-    assert(atom->sectionChoice() == DefinedAtom::sectionBasedOnContent);
     if (isEligible(atom))
       appendAtom(atom);
   }





More information about the llvm-commits mailing list