[llvm] r260486 - [readobj] Sort switch by enum value.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 20:59:32 PST 2016


Author: mspencer
Date: Wed Feb 10 22:59:32 2016
New Revision: 260486

URL: http://llvm.org/viewvc/llvm-project?rev=260486&view=rev
Log:
[readobj] Sort switch by enum value.

Sort by enum value, but keep related entries adjacent. This makes it
easier to compare against documentation.

Modified:
    llvm/trunk/tools/llvm-readobj/ELFDumper.cpp

Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=260486&r1=260485&r2=260486&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Feb 10 22:59:32 2016
@@ -998,6 +998,22 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
 
   for (const Elf_Shdr &Sec : Obj->sections()) {
     switch (Sec.sh_type) {
+    case ELF::SHT_SYMTAB:
+      if (DotSymtabSec != nullptr)
+        reportError("Multilpe SHT_SYMTAB");
+      DotSymtabSec = &Sec;
+      break;
+    case ELF::SHT_DYNSYM:
+      if (DotDynSymSec != nullptr)
+        reportError("Multilpe SHT_DYNSYM");
+      DotDynSymSec = &Sec;
+      break;
+    case ELF::SHT_SYMTAB_SHNDX: {
+      ErrorOr<ArrayRef<Elf_Word>> TableOrErr = Obj->getSHNDXTable(Sec);
+      error(TableOrErr.getError());
+      ShndxTable = *TableOrErr;
+      break;
+    }
     case ELF::SHT_GNU_versym:
       if (dot_gnu_version_sec != nullptr)
         reportError("Multiple SHT_GNU_versym");
@@ -1013,22 +1029,6 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
         reportError("Multilpe SHT_GNU_verneed");
       dot_gnu_version_r_sec = &Sec;
       break;
-    case ELF::SHT_DYNSYM:
-      if (DotDynSymSec != nullptr)
-        reportError("Multilpe SHT_DYNSYM");
-      DotDynSymSec = &Sec;
-      break;
-    case ELF::SHT_SYMTAB:
-      if (DotSymtabSec != nullptr)
-        reportError("Multilpe SHT_SYMTAB");
-      DotSymtabSec = &Sec;
-      break;
-    case ELF::SHT_SYMTAB_SHNDX: {
-      ErrorOr<ArrayRef<Elf_Word>> TableOrErr = Obj->getSHNDXTable(Sec);
-      error(TableOrErr.getError());
-      ShndxTable = *TableOrErr;
-      break;
-    }
     }
   }
 
@@ -1058,14 +1058,15 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
       GnuHashTable =
           reinterpret_cast<const Elf_GnuHash *>(toMappedAddr(Dyn.getPtr()));
       break;
-    case ELF::DT_REL:
-      DynRelRegion.Addr = toMappedAddr(Dyn.getPtr());
+    case ELF::DT_STRTAB:
+      StringTableBegin = (const char *)toMappedAddr(Dyn.getPtr());
       break;
-    case ELF::DT_RELSZ:
-      DynRelRegion.Size = Dyn.getVal();
+    case ELF::DT_STRSZ:
+      StringTableSize = Dyn.getVal();
       break;
-    case ELF::DT_RELENT:
-      DynRelRegion.EntSize = Dyn.getVal();
+    case ELF::DT_SYMTAB:
+      DynSymStart =
+          reinterpret_cast<const Elf_Sym *>(toMappedAddr(Dyn.getPtr()));
       break;
     case ELF::DT_RELA:
       DynRelaRegion.Addr = toMappedAddr(Dyn.getPtr());
@@ -1079,15 +1080,14 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile
     case ELF::DT_SONAME:
       SONameOffset = Dyn.getVal();
       break;
-    case ELF::DT_STRTAB:
-      StringTableBegin = (const char *)toMappedAddr(Dyn.getPtr());
+    case ELF::DT_REL:
+      DynRelRegion.Addr = toMappedAddr(Dyn.getPtr());
       break;
-    case ELF::DT_STRSZ:
-      StringTableSize = Dyn.getVal();
+    case ELF::DT_RELSZ:
+      DynRelRegion.Size = Dyn.getVal();
       break;
-    case ELF::DT_SYMTAB:
-      DynSymStart =
-          reinterpret_cast<const Elf_Sym *>(toMappedAddr(Dyn.getPtr()));
+    case ELF::DT_RELENT:
+      DynRelRegion.EntSize = Dyn.getVal();
       break;
     }
   }




More information about the llvm-commits mailing list