2012-11-14 20:18:34 +00:00
|
|
|
//===-- ObjectImageCommon.h - Format independent executuable object image -===//
|
|
|
|
//
|
2013-12-07 11:21:42 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
2012-11-14 20:18:34 +00:00
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares a file format independent ObjectImage class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
|
|
|
#define LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
|
|
|
|
|
|
|
#include "llvm/ExecutionEngine/ObjectBuffer.h"
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "llvm/ExecutionEngine/ObjectImage.h"
|
|
|
|
#include "llvm/Object/ObjectFile.h"
|
2012-11-14 20:18:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-01-08 04:09:09 +00:00
|
|
|
namespace object {
|
|
|
|
class ObjectFile;
|
|
|
|
}
|
|
|
|
|
2012-11-14 20:18:34 +00:00
|
|
|
class ObjectImageCommon : public ObjectImage {
|
|
|
|
ObjectImageCommon(); // = delete
|
|
|
|
ObjectImageCommon(const ObjectImageCommon &other); // = delete
|
2014-03-08 07:51:20 +00:00
|
|
|
void anchor() override;
|
2012-11-14 20:18:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
object::ObjectFile *ObjFile;
|
|
|
|
|
|
|
|
// This form of the constructor allows subclasses to use
|
|
|
|
// format-specific subclasses of ObjectFile directly
|
|
|
|
ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
|
|
|
|
: ObjectImage(Input), // saves Input as Buffer and takes ownership
|
|
|
|
ObjFile(Obj)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
ObjectImageCommon(ObjectBuffer* Input)
|
|
|
|
: ObjectImage(Input) // saves Input as Buffer and takes ownership
|
|
|
|
{
|
2014-01-22 00:14:49 +00:00
|
|
|
ObjFile =
|
|
|
|
object::ObjectFile::createObjectFile(Buffer->getMemBuffer()).get();
|
2012-11-14 20:18:34 +00:00
|
|
|
}
|
2014-01-08 04:09:09 +00:00
|
|
|
ObjectImageCommon(object::ObjectFile* Input)
|
|
|
|
: ObjectImage(NULL), ObjFile(Input) {}
|
2012-11-14 20:18:34 +00:00
|
|
|
virtual ~ObjectImageCommon() { delete ObjFile; }
|
|
|
|
|
2014-03-08 07:51:20 +00:00
|
|
|
object::symbol_iterator begin_symbols() const override
|
|
|
|
{ return ObjFile->symbol_begin(); }
|
|
|
|
object::symbol_iterator end_symbols() const override
|
|
|
|
{ return ObjFile->symbol_end(); }
|
2012-11-14 20:18:34 +00:00
|
|
|
|
2014-03-08 07:51:20 +00:00
|
|
|
object::section_iterator begin_sections() const override
|
|
|
|
{ return ObjFile->section_begin(); }
|
|
|
|
object::section_iterator end_sections() const override
|
|
|
|
{ return ObjFile->section_end(); }
|
2012-11-14 20:18:34 +00:00
|
|
|
|
2014-03-08 07:51:20 +00:00
|
|
|
/* Triple::ArchType */ unsigned getArch() const override
|
|
|
|
{ return ObjFile->getArch(); }
|
2012-11-14 20:18:34 +00:00
|
|
|
|
2014-03-08 07:51:20 +00:00
|
|
|
StringRef getData() const override { return ObjFile->getData(); }
|
2012-11-14 20:18:34 +00:00
|
|
|
|
2014-03-08 07:51:20 +00:00
|
|
|
object::ObjectFile* getObjectFile() const override { return ObjFile; }
|
2013-01-25 22:50:58 +00:00
|
|
|
|
2012-11-14 20:18:34 +00:00
|
|
|
// Subclasses can override these methods to update the image with loaded
|
|
|
|
// addresses for sections and common symbols
|
2014-03-08 07:51:20 +00:00
|
|
|
void updateSectionAddress(const object::SectionRef &Sec,
|
|
|
|
uint64_t Addr) override {}
|
|
|
|
void updateSymbolAddress(const object::SymbolRef &Sym,
|
|
|
|
uint64_t Addr) override {}
|
2012-11-14 20:18:34 +00:00
|
|
|
|
|
|
|
// Subclasses can override these methods to provide JIT debugging support
|
2014-03-08 07:51:20 +00:00
|
|
|
void registerWithDebugger() override {}
|
|
|
|
void deregisterWithDebugger() override {}
|
2012-11-14 20:18:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
|