[lld] r238176 - [Mips] Add Elf_Mips_Options::getRegInfoDesc() function to retrieve an ODK_REGINFO descriptor

Simon Atanasyan simon at atanasyan.com
Mon May 25 23:05:07 PDT 2015


Author: atanasyan
Date: Tue May 26 01:05:07 2015
New Revision: 238176

URL: http://llvm.org/viewvc/llvm-project?rev=238176&view=rev
Log:
[Mips] Add Elf_Mips_Options::getRegInfoDesc() function to retrieve an ODK_REGINFO descriptor

No functional changes.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=238176&r1=238175&r2=238176&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Tue May 26 01:05:07 2015
@@ -178,9 +178,9 @@ private:
         const auto *opt =
             reinterpret_cast<const Elf_Mips_Options *>(raw.data());
         if (opt->kind == ODK_REGINFO) {
-          const auto *regInfo = reinterpret_cast<const Elf_RegInfo *>(opt + 1);
-          ctx.mergeReginfoMask(*regInfo);
-          _gp0 = regInfo->ri_gp_value;
+          const Elf_RegInfo &regInfo = opt->getRegInfoDesc();
+          ctx.mergeReginfoMask(regInfo);
+          _gp0 = regInfo.ri_gp_value;
           break;
         }
         raw = raw.slice(opt->size);

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h?rev=238176&r1=238175&r2=238176&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h Tue May 26 01:05:07 2015
@@ -41,6 +41,12 @@ template <class ELFT> struct Elf_Mips_Op
   Elf_Half section; // Section header index of section affected,
                     // or 0 for global options
   Elf_Word info;    // Kind-specific information
+
+  const Elf_RegInfo<ELFT> &getRegInfoDesc() const {
+    assert(kind == llvm::ELF::ODK_REGINFO);
+    return *reinterpret_cast<const Elf_RegInfo<ELFT> *>(
+               (const uint8_t *)this + sizeof(Elf_Mips_Options));
+  }
 };
 
 } // end namespace object.





More information about the llvm-commits mailing list