Bug 1081034 part 1 - Move GetSymbolPtr, Contains and FindExidx from CustomElf to BaseElf. r=nfroyd

This commit is contained in:
Mike Hommey 2014-10-16 09:19:46 +09:00
parent f1252281fe
commit 1267fa50ff
4 changed files with 33 additions and 40 deletions

View File

@ -22,6 +22,12 @@ BaseElf::Hash(const char *symbol)
return h;
}
void *
BaseElf::GetSymbolPtr(const char *symbol) const
{
return GetSymbolPtr(symbol, Hash(symbol));
}
void *
BaseElf::GetSymbolPtr(const char *symbol, unsigned long hash) const
{
@ -53,3 +59,22 @@ BaseElf::GetSymbol(const char *symbol, unsigned long hash) const
}
return nullptr;
}
bool
BaseElf::Contains(void *addr) const
{
return base.Contains(addr);
}
#ifdef __ARM_EABI__
const void *
BaseElf::FindExidx(int *pcount) const
{
if (arm_exidx) {
*pcount = arm_exidx.numElements();
return arm_exidx;
}
*pcount = 0;
return nullptr;
}
#endif

View File

@ -44,12 +44,12 @@ 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; };
virtual void *GetSymbolPtr(const char *symbol) const;
virtual bool Contains(void *addr) const;
virtual void *GetBase() const { return GetPtr(0); }
#ifdef __ARM_EABI__
virtual const void *FindExidx(int *pcount) const { return NULL; };
virtual const void *FindExidx(int *pcount) const;
#endif
virtual Mappable *GetMappable() const { return NULL; };
@ -96,6 +96,11 @@ public:
/* Symbol table */
UnsizedArray<Elf::Sym> symtab;
#ifdef __ARM_EABI__
/* ARM.exidx information used by FindExidx */
Array<uint32_t[2]> arm_exidx;
#endif
};
#endif /* BaseElf_h */

View File

@ -278,12 +278,6 @@ CustomElf::~CustomElf()
ElfLoader::Singleton.Forget(this);
}
void *
CustomElf::GetSymbolPtr(const char *symbol) const
{
return BaseElf::GetSymbolPtr(symbol, Hash(symbol));
}
void *
CustomElf::GetSymbolPtrInDeps(const char *symbol) const
{
@ -359,25 +353,6 @@ CustomElf::GetSymbolPtrInDeps(const char *symbol) const
return nullptr;
}
bool
CustomElf::Contains(void *addr) const
{
return base.Contains(addr);
}
#ifdef __ARM_EABI__
const void *
CustomElf::FindExidx(int *pcount) const
{
if (arm_exidx) {
*pcount = arm_exidx.numElements();
return arm_exidx;
}
*pcount = 0;
return nullptr;
}
#endif
void
CustomElf::stats(const char *when) const
{

View File

@ -35,13 +35,6 @@ public:
* Inherited from LibHandle/BaseElf
*/
virtual ~CustomElf();
virtual void *GetSymbolPtr(const char *symbol) const;
virtual bool Contains(void *addr) const;
virtual void *GetBase() const { return GetPtr(0); }
#ifdef __ARM_EABI__
virtual const void *FindExidx(int *pcount) const;
#endif
protected:
virtual Mappable *GetMappable() const;
@ -161,11 +154,6 @@ private:
bool initialized;
bool has_text_relocs;
#ifdef __ARM_EABI__
/* ARM.exidx information used by FindExidx */
Array<uint32_t[2]> arm_exidx;
#endif
};
#endif /* CustomElf_h */