30 #if !defined(_SourceFile_h_) 31 #define _SourceFile_h_ 36 #include "smart_ptr.h" 37 #include "DataSource.h" 38 #include "DataTarget.h" 39 #include "StringMatcher.h" 40 #include "OptionContext.h" 106 virtual bool supportsNamedSections()
const = 0;
107 virtual bool supportsNamedSymbols()
const = 0;
136 virtual DataTarget *createDataTargetForSection(
const std::string §ion) {
return NULL; }
137 virtual DataTarget *createDataTargetForSymbol(
const std::string &symbol) {
return NULL; }
138 virtual DataTarget *createDataTargetForEntryPoint();
143 virtual bool hasSymbol(
const std::string &name) {
return false; }
173 virtual bool supportsNamedSections()
const {
return false; }
174 virtual bool supportsNamedSymbols()
const {
return false; }
185 void guessEntryPointAndStackPointer();
198 uint32_t m_entry_point;
199 uint32_t m_stack_pointer;
204 #endif // _SourceFile_h_ smart_ptr< OptionContext > m_options
Table of option values.
Definition: src/blfwk/SourceFile.h:154
Definition: src/blfwk/SourceFile.h:68
ptr_type get()
Return the current pointer value.
Definition: apps/elftosb/common/smart_ptr.h:43
Definition: BlfwkErrors.h:16
Definition: src/blfwk/SourceFile.h:67
source_file_t
Set of supported executable image file formats.
Definition: src/blfwk/SourceFile.h:63
virtual uint32_t getSymbolValue(const std::string &name)
Returns the value of a symbol.
Definition: src/blfwk/SourceFile.h:146
virtual bool hasEntryPoint()
Returns true if an entry point was set in the file.
Definition: src/blfwk/SourceFile.h:190
virtual uint32_t getEntryPointAddress()
Returns the entry point address.
Definition: src/blfwk/SourceFile.h:192
Binary data file.
Definition: src/blfwk/SourceFile.h:165
virtual void close()
Closes the file.
Definition: src/blfwk/src/SourceFile.cpp:147
smart_ptr< std::ifstream > m_stream
File stream, or NULL if file is closed.
Definition: src/blfwk/SourceFile.h:153
Abstract base class for the target address or range of data.
Definition: src/blfwk/DataTarget.h:57
Pure abstract interface class to a table of options.
Definition: src/blfwk/OptionContext.h:41
Simple, standard smart pointer class.
Definition: apps/elftosb/common/smart_ptr.h:18
std::string m_path
Path to the file.
Definition: src/blfwk/SourceFile.h:152
static SourceFile * openFile(const std::string &path)
Definition: src/blfwk/src/SourceFile.cpp:62
unsigned m_size
The size in bytes of the file.
Definition: src/blfwk/SourceFile.h:156
unsigned getSize() const
Get the size in bytes of the file.
Definition: src/blfwk/SourceFile.h:91
virtual DataSource * createDataSource()=0
Creates a data source from the entire file.
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
SourceFile(const std::string &path, source_file_t filetype)
Default constructor.
Definition: src/blfwk/src/SourceFile.cpp:113
virtual bool hasEntryPoint()=0
Returns true if an entry point was set in the file.
virtual uint32_t getEntryPointAddress()
Returns the entry point address.
Definition: src/blfwk/SourceFile.h:131
const std::string & getPath() const
Returns the path to the file.
Definition: src/blfwk/SourceFile.h:89
virtual bool hasSymbol(const std::string &name)
Returns whether a symbol exists in the source file.
Definition: src/blfwk/SourceFile.h:144
source_file_t m_filetype
Image file type.
Definition: src/blfwk/SourceFile.h:155
Abstract interface class used to select strings by name.
Definition: src/blfwk/StringMatcher.h:40
virtual void open()
Opens the file.
Definition: src/blfwk/src/SourceFile.cpp:137
virtual ~SourceFile()
Destructor.
Definition: src/blfwk/src/SourceFile.cpp:128
virtual DataSource * createDataSource(StringMatcher &matcher)
Creates a data source out of one or more sections of the file.
Definition: src/blfwk/SourceFile.h:120
source_file_t getFileType() const
Return the file type.
Definition: src/blfwk/SourceFile.h:87
Abstract base class for data sources.
Definition: src/blfwk/DataSource.h:56
const OptionContext * getOptions() const
Return the option context.
Definition: src/blfwk/SourceFile.h:85
std::ifstream * getStream()
Internal access to the input stream object.
Definition: src/blfwk/SourceFile.h:159
Definition: src/blfwk/SourceFile.h:66
uint32_t getStackPointer()
Returns the stack pointer.
Definition: src/blfwk/SourceFile.h:194
virtual bool isOpen() const
Returns whether the file is already open.
Definition: src/blfwk/SourceFile.h:101
Definition: src/blfwk/SourceFile.h:69
virtual unsigned getSymbolSize(const std::string &name)
Returns the size of a symbol.
Definition: src/blfwk/SourceFile.h:148
Definition: src/blfwk/SourceFile.h:65
void setOptions(OptionContext *context)
Set the option context.
Definition: src/blfwk/SourceFile.h:83