[lld] r276811 - Move code for MIPS from createInputSection to initializeSections.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 14:26:02 PDT 2016


Author: ruiu
Date: Tue Jul 26 16:26:02 2016
New Revision: 276811

URL: http://llvm.org/viewvc/llvm-project?rev=276811&view=rev
Log:
Move code for MIPS from createInputSection to initializeSections.

We already have code for ARM in initializeSections, so this
is more consistent.

Differential Revision: https://reviews.llvm.org/D22833

Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=276811&r1=276810&r2=276811&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Jul 26 16:26:02 2016
@@ -252,6 +252,14 @@ void elf::ObjectFile<ELFT>::initializeSe
       // they can be used to reason about object compatibility.
       Sections[I] = &InputSection<ELFT>::Discarded;
       break;
+    case SHT_MIPS_REGINFO:
+      MipsReginfo.reset(new MipsReginfoInputSection<ELFT>(this, &Sec));
+      Sections[I] = MipsReginfo.get();
+      break;
+    case SHT_MIPS_OPTIONS:
+      MipsOptions.reset(new MipsOptionsInputSection<ELFT>(this, &Sec));
+      Sections[I] = MipsOptions.get();
+      break;
     default:
       Sections[I] = createInputSection(Sec);
     }
@@ -298,19 +306,6 @@ elf::ObjectFile<ELFT>::createInputSectio
   if (Config->StripDebug && Name.startswith(".debug"))
     return &InputSection<ELFT>::Discarded;
 
-  // A MIPS object file has a special sections that contain register
-  // usage info, which need to be handled by the linker specially.
-  if (Config->EMachine == EM_MIPS) {
-    switch (Sec.sh_type) {
-    case SHT_MIPS_REGINFO:
-      MipsReginfo.reset(new MipsReginfoInputSection<ELFT>(this, &Sec));
-      return MipsReginfo.get();
-    case SHT_MIPS_OPTIONS:
-      MipsOptions.reset(new MipsOptionsInputSection<ELFT>(this, &Sec));
-      return MipsOptions.get();
-    }
-  }
-
   // The linker merges EH (exception handling) frames and creates a
   // .eh_frame_hdr section for runtime. So we handle them with a special
   // class. For relocatable outputs, they are just passed through.




More information about the llvm-commits mailing list