Bug 1078837 part 1 - Move CustomElf::mappable to BaseElf. r=nfroyd
--- 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;