[lld] r238779 - COFF: Use Chunk instead of its derived classes.

Rui Ueyama ruiu at google.com
Mon Jun 1 14:05:24 PDT 2015


Author: ruiu
Date: Mon Jun  1 16:05:24 2015
New Revision: 238779

URL: http://llvm.org/viewvc/llvm-project?rev=238779&view=rev
Log:
COFF: Use Chunk instead of its derived classes.

I'm adding ordinal-only (nameless) imports to the import table.
The chunk for that type is going to be different from LookupChunk.
Without this change, we cannot add objects of the new type to the
vectors.

Modified:
    lld/trunk/COFF/Chunks.cpp
    lld/trunk/COFF/Chunks.h
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=238779&r1=238778&r2=238779&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Mon Jun  1 16:05:24 2015
@@ -201,7 +201,7 @@ ImportTable::ImportTable(StringRef N,
     HintNameTables.push_back(
         new HintNameChunk(S->getExportName(), S->getOrdinal()));
 
-  for (HintNameChunk *H : HintNameTables) {
+  for (Chunk *H : HintNameTables) {
     LookupTables.push_back(new LookupChunk(H));
     AddressTables.push_back(new LookupChunk(H));
   }

Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=238779&r1=238778&r2=238779&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Mon Jun  1 16:05:24 2015
@@ -206,24 +206,24 @@ private:
 // A chunk for the import descriptor table.
 class LookupChunk : public Chunk {
 public:
-  explicit LookupChunk(HintNameChunk *H) : HintName(H) {}
+  explicit LookupChunk(Chunk *C) : HintName(C) {}
   bool hasData() const override { return false; }
   size_t getSize() const override { return sizeof(uint64_t); }
   void applyRelocations(uint8_t *Buf) override;
-  HintNameChunk *HintName;
+  Chunk *HintName;
 };
 
 // A chunk for the import descriptor table.
 class DirectoryChunk : public Chunk {
 public:
-  explicit DirectoryChunk(StringChunk *N) : DLLName(N) {}
+  explicit DirectoryChunk(Chunk *N) : DLLName(N) {}
   bool hasData() const override { return false; }
   size_t getSize() const override { return sizeof(ImportDirectoryTableEntry); }
   void applyRelocations(uint8_t *Buf) override;
 
-  StringChunk *DLLName;
-  LookupChunk *LookupTab;
-  LookupChunk *AddressTab;
+  Chunk *DLLName;
+  Chunk *LookupTab;
+  Chunk *AddressTab;
 };
 
 // A chunk for the import descriptor table representing.
@@ -246,9 +246,9 @@ public:
   ImportTable(StringRef DLLName, std::vector<DefinedImportData *> &Symbols);
   StringChunk *DLLName;
   DirectoryChunk *DirTab;
-  std::vector<LookupChunk *> LookupTables;
-  std::vector<LookupChunk *> AddressTables;
-  std::vector<HintNameChunk *> HintNameTables;
+  std::vector<Chunk *> LookupTables;
+  std::vector<Chunk *> AddressTables;
+  std::vector<Chunk *> HintNameTables;
 };
 
 } // namespace coff

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=238779&r1=238778&r2=238779&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Mon Jun  1 16:05:24 2015
@@ -178,7 +178,7 @@ void Writer::createImportTables() {
 
   // Add the import lookup tables.
   for (ImportTable &T : Tabs) {
-    for (LookupChunk *C : T.LookupTables)
+    for (Chunk *C : T.LookupTables)
       Idata->addChunk(C);
     Idata->addChunk(new NullChunk(sizeof(uint64_t)));
   }
@@ -186,7 +186,7 @@ void Writer::createImportTables() {
   // Add the import address tables. Their contents are the same as the
   // lookup tables.
   for (ImportTable &T : Tabs) {
-    for (LookupChunk *C : T.AddressTables)
+    for (Chunk *C : T.AddressTables)
       Idata->addChunk(C);
     Idata->addChunk(new NullChunk(sizeof(uint64_t)));
     ImportAddressTableSize += (T.AddressTables.size() + 1) * sizeof(uint64_t);
@@ -195,7 +195,7 @@ void Writer::createImportTables() {
 
   // Add the hint name table.
   for (ImportTable &T : Tabs)
-    for (HintNameChunk *C : T.HintNameTables)
+    for (Chunk *C : T.HintNameTables)
       Idata->addChunk(C);
 
   // Add DLL names.





More information about the llvm-commits mailing list