blfwk::ELFSourceFile Class Reference

Executable and Loading Format (ELF) source file. More...

`#include <ELFSourceFile.h>`

Inheritance diagram for blfwk::ELFSourceFile:
[legend]
Collaboration diagram for blfwk::ELFSourceFile:
[legend]

## Classes

class | ELFDataSource
| A data source with ELF file sections as the contents. More...

## Public Member Functions

| ELFSourceFile (const std::string &path)
| Default constructor.
virtual | ~ELFSourceFile ()
| Destructor.
virtual DataSource * | createDataSource (const std::vector< uint32_t > &baseAddress, bool match)
| Creates a data source from sections of the file that either match or do not match the.
Opening and closing
virtual void | open ()
| Opens the file.
virtual void | close ()
| Closes the file.
Format capabilities
virtual bool | supportsNamedSections () const
virtual bool | supportsNamedSymbols () const
Data source
virtual DataSource * | createDataSource ()
| Creates a data source from the entire file. More...
virtual DataSource * | createDataSource (StringMatcher &matcher)
| Creates a data source from one or more sections of the file.
Entry point
virtual bool | hasEntryPoint ()
| Returns true if an entry point was set in the file. More...
virtual uint32_t | getEntryPointAddress ()
| Returns the entry point address. More...
Data target
virtual DataTarget * | createDataTargetForSection (const std::string &section)
virtual DataTarget * | createDataTargetForSymbol (const std::string &symbol)
Symbols
virtual bool | hasSymbol (const std::string &name)
| Returns whether a symbol exists in the source file.
virtual uint32_t | getSymbolValue (const std::string &name)
| Returns the value of a symbol.
virtual unsigned | getSymbolSize (const std::string &name)
| Returns the size of a symbol.
Direct ELF format access
StELFFile * | getELFFile ()
| Returns the underlying StELFFile object.
bool | lookupSymbol (const std::string &name, Elf32_Sym &info)
| Gets information about a symbol in the ELF file. More...
Public Member Functions inherited from blfwk::SourceFile
| SourceFile (const std::string &path, source_file_t filetype)
| Default constructor.
virtual | ~SourceFile ()
| Destructor. More...
void | setOptions (OptionContext *context)
| Set the option context. More...
const OptionContext * | getOptions () const
| Return the option context.
source_file_t | getFileType () const
| Return the file type.
const std::string & | getPath () const
| Returns the path to the file.
unsigned | getSize () const
| Get the size in bytes of the file.
virtual bool | isOpen () const
| Returns whether the file is already open.
virtual DataSource * | createDataSource (const std::string &section)
| Creates a data source out of one section of the file. More...
virtual DataTarget * | createDataTargetForEntryPoint ()

## Static Public Member Functions

static bool | isELFFile (std::istream &stream)
| Identifies whether the stream contains an ELF file.
Static Public Member Functions inherited from blfwk::SourceFile
static SourceFile * | openFile (const std::string &path)

## Protected Member Functions

elf_toolset_t | readToolsetOption ()
| Parses the toolset option value.
secinfo_clear_t | readSecinfoClearOption ()
| Reads the secinfoClear option. More...
Protected Member Functions inherited from blfwk::SourceFile
std::ifstream * | getStream ()
| Internal access to the input stream object.

## Protected Attributes

smart_ptr< StELFFile > | m_file
| Parser for the ELF file.
elf_toolset_t | m_toolset
| Toolset that produced the ELF file.
secinfo_clear_t | m_secinfoOption
| How to deal with the .secinfo section. Ignored if the toolset is not GHS.
Protected Attributes inherited from blfwk::SourceFile
std::string | m_path
| Path to the file.
smart_ptr< std::ifstream > | m_stream
| File stream, or NULL if file is closed.
smart_ptr< OptionContext > | m_options
| Table of option values.
source_file_t | m_filetype
| Image file type.
unsigned | m_size
| The size in bytes of the file.

## Additional Inherited Members

Public Types inherited from blfwk::SourceFile
enum | source_file_t { kBinarySourceFile, kELFSourceFile, kIntelHexSourceFile, kSBSourceFile, kSRecordSourceFile }
| Set of supported executable image file formats. More...

## Detailed Description

Executable and Loading Format (ELF) source file.

## Member Function Documentation

DataSource * ELFSourceFile::createDataSource | ( |  | ) |

virtual

Creates a data source from the entire file.

To create a data source for all sections of the ELF file, a WildcardMatcher is instantiated and passed to createDataSource(StringMatcher&).

Implements blfwk::SourceFile.

DataTarget * ELFSourceFile::createDataTargetForSection | ( | const std::string & | section | ) |

virtual

Returns
  A DataTarget that describes the named section.

Return values

  NULL | There was no section with the requested name.

Reimplemented from blfwk::SourceFile.

DataTarget * ELFSourceFile::createDataTargetForSymbol | ( | const std::string & | symbol | ) |

virtual

Returns
  A DataTarget instance pointing at the requested symbol.

Return values

  NULL | No symbol matching the requested name was found.

Reimplemented from blfwk::SourceFile.

uint32_t ELFSourceFile::getEntryPointAddress | ( |  | ) |

virtual

Returns the entry point address.

The StELFFile::getTypeOfSymbolAtIndex() method uses different methods of determining ARM/Thumb mode depending on the toolset.

Reimplemented from blfwk::SourceFile.

bool ELFSourceFile::hasEntryPoint | ( |  | ) |

virtual

Returns true if an entry point was set in the file.

It is assumed that all ELF files have an entry point.

Implements blfwk::SourceFile.

bool ELFSourceFile::lookupSymbol | ( | const std::string & | name,
|  | Elf32_Sym & | info
| ) |  |

Gets information about a symbol in the ELF file.

Parameters

  | name | The name of the symbol on which info is wanted.
  [out] | info | Upon succssful return this is filled in with the symbol's information.

Return values

  true | The symbol was found and info is valid.
  false | No symbol with name was found in the file.

secinfo_clear_t ELFSourceFile::readSecinfoClearOption | ( |  | ) |

protected

Reads the secinfoClear option.

It is up to the caller to convert from kSecinfoDefault to the actual default value.

The documentation for this class was generated from the following files:

- src/blfwk/ELFSourceFile.h
- src/blfwk/src/ELFSourceFile.cpp