Bug 1078837 part 1 - Move CustomElf::mappable to BaseElf. r=nfroyd
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 16 Oct 2014 09:19:45 +0900
changeset 222902 b483b12025b0f6135ffa65070cdc250942d91b10
parent 222901 1f5fdd080b46461c34cfa2c6563358b8c74b2331
child 222903 fd07aa0b6a04cfdffb01505315711a2869f96576
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-esr52@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1078837
milestone36.0a1
Bug 1078837 part 1 - Move CustomElf::mappable to BaseElf. r=nfroyd
mozglue/linker/BaseElf.h
mozglue/linker/CustomElf.h
--- a/mozglue/linker/BaseElf.h
+++ b/mozglue/linker/BaseElf.h
@@ -28,18 +28,21 @@ public:
   void *GetSymbolPtr(const char *symbol, unsigned long hash) const;
 
   /**
    * Returns a pointer to the Elf Symbol in the Dynamic Symbol table
    * corresponding to the given symbol name (with a pre-computed hash).
    */
   const Elf::Sym *GetSymbol(const char *symbol, unsigned long hash) const;
 
-  BaseElf(const char *path)
-  : LibHandle(path) { }
+  BaseElf(const char *path, Mappable *mappable = nullptr)
+  : LibHandle(path)
+  , mappable(mappable)
+  {
+  }
 
 protected:
    /**
     * Inherited from LibHandle. Those are temporary and are not supposed to
     * be used.
     */
    virtual void *GetSymbolPtr(const char *symbol) const { return NULL; };
    virtual bool Contains(void *addr) const { return false; };
@@ -70,16 +73,19 @@ public:
   template <typename T>
   const T *GetPtr(const Elf::Addr offset) const
   {
     if (reinterpret_cast<void *>(offset) > base)
       return reinterpret_cast<const T *>(offset);
     return reinterpret_cast<const T *>(base + offset);
   }
 
+  /* Appropriated Mappable */
+  mozilla::RefPtr<Mappable> mappable;
+
   /* Base address where the library is loaded */
   MappedPtr base;
 
   /* Buckets and chains for the System V symbol hash table */
   Array<Elf::Word> buckets;
   UnsizedArray<Elf::Word> chains;
 
 /* protected: */
--- a/mozglue/linker/CustomElf.h
+++ b/mozglue/linker/CustomElf.h
@@ -61,19 +61,18 @@ private:
    * in the Elf object.
    */
   void *GetSymbolPtrInDeps(const char *symbol) const;
 
   /**
    * Private constructor
    */
   CustomElf(Mappable *mappable, const char *path)
-  : BaseElf(path)
+  : BaseElf(path, mappable)
   , link_map()
-  , mappable(mappable)
   , init(0)
   , fini(0)
   , initialized(false)
   , has_text_relocs(false)
   { }
 
   /**
    * Loads an Elf segment defined by the given PT_LOAD header.
@@ -131,19 +130,16 @@ private:
   /**
    * Call a function given a an address relative to the library base
    */
   void CallFunction(Elf::Addr addr) const
   {
     return CallFunction(GetPtr(addr));
   }
 
-  /* Appropriated Mappable */
-  mozilla::RefPtr<Mappable> mappable;
-
   /* List of dependent libraries */
   std::vector<mozilla::RefPtr<LibHandle> > dependencies;
 
   /* List of .rel.dyn/.rela.dyn relocations */
   Array<Elf::Reloc> relocations;
 
   /* List of .rel.plt/.rela.plt relocation */
   Array<Elf::Reloc> jumprels;