COFF: reorder the table construction
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 10 Aug 2016 04:37:56 +0000 (04:37 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 10 Aug 2016 04:37:56 +0000 (04:37 +0000)
Reorder the table setup to mirror the indices corresponding to them.  This means
that the table values are filled out as per the enumeration ordering.  Doing so
makes it easier to identify a particular table.  NFC.

llvm-svn: 278199

lld/COFF/Writer.cpp

index d8077df..ea0dcb4 100644 (file)
@@ -584,23 +584,18 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
     Dir[IAT].RelativeVirtualAddress = Idata.getIATRVA();
     Dir[IAT].Size = Idata.getIATSize();
   }
-  if (!DelayIdata.empty()) {
-    Dir[DELAY_IMPORT_DESCRIPTOR].RelativeVirtualAddress =
-        DelayIdata.getDirRVA();
-    Dir[DELAY_IMPORT_DESCRIPTOR].Size = DelayIdata.getDirSize();
-  }
   if (OutputSection *Sec = findSection(".rsrc")) {
     Dir[RESOURCE_TABLE].RelativeVirtualAddress = Sec->getRVA();
     Dir[RESOURCE_TABLE].Size = Sec->getVirtualSize();
   }
-  if (OutputSection *Sec = findSection(".reloc")) {
-    Dir[BASE_RELOCATION_TABLE].RelativeVirtualAddress = Sec->getRVA();
-    Dir[BASE_RELOCATION_TABLE].Size = Sec->getVirtualSize();
-  }
   if (OutputSection *Sec = findSection(".pdata")) {
     Dir[EXCEPTION_TABLE].RelativeVirtualAddress = Sec->getRVA();
     Dir[EXCEPTION_TABLE].Size = Sec->getVirtualSize();
   }
+  if (OutputSection *Sec = findSection(".reloc")) {
+    Dir[BASE_RELOCATION_TABLE].RelativeVirtualAddress = Sec->getRVA();
+    Dir[BASE_RELOCATION_TABLE].Size = Sec->getVirtualSize();
+  }
   if (Symbol *Sym = Symtab->findUnderscore("_tls_used")) {
     if (Defined *B = dyn_cast<Defined>(Sym->Body)) {
       Dir[TLS_TABLE].RelativeVirtualAddress = B->getRVA();
@@ -626,6 +621,11 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
       Dir[LOAD_CONFIG_TABLE].Size = LoadConfigSize;
     }
   }
+  if (!DelayIdata.empty()) {
+    Dir[DELAY_IMPORT_DESCRIPTOR].RelativeVirtualAddress =
+        DelayIdata.getDirRVA();
+    Dir[DELAY_IMPORT_DESCRIPTOR].Size = DelayIdata.getDirSize();
+  }
 
   // Write section table
   for (OutputSection *Sec : OutputSections) {