RTEMS Linker  0.0.1
RTEMS Tools Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rld::elf::file Class Reference

#include <rld-elf.h>

Public Member Functions

 file ()
 
 ~file ()
 
void begin (const std::string &name, int fd, const bool writable=false)
 
void begin (const std::string &name, file &archive, off_t offset)
 
void end ()
 
void write ()
 
void load_header ()
 
unsigned int machinetype () const
 
unsigned int type () const
 
unsigned int object_class () const
 
unsigned int data_type () const
 
bool is_archive () const
 
bool is_executable () const
 
bool is_relocatable () const
 
int section_count () const
 
void load_sections ()
 
void get_sections (sections &filtered_secs, unsigned int type)
 
sectionget_section (int index)
 
int strings_section () const
 
std::string get_string (int section, size_t offset)
 
std::string get_string (size_t offset)
 
void load_symbols ()
 
void get_symbols (rld::symbols::pointers &filtered_syms, bool unresolved=false, bool local=false, bool weak=true, bool global=true)
 
const symbols::symbolget_symbol (const int index) const
 
void load_relocations ()
 
void clear_relocations ()
 
void set_header (elf_half type, int class_, elf_half machinetype, unsigned char datatype)
 
void add (section &sec)
 
void add (program_header &phdr)
 
elfget_elf ()
 
const std::string & name () const
 
bool is_writable () const
 

Detailed Description

An ELF file.

Constructor & Destructor Documentation

rld::elf::file::file ( )

Construct an ELF file.

rld::elf::file::~file ( )

Destruct the ELF file object.

Member Function Documentation

void rld::elf::file::add ( section sec)

Add a section to the ELF file if writable.

void rld::elf::file::add ( program_header phdr)

Add a program header to the ELF file if writable.

void rld::elf::file::begin ( const std::string &  name,
int  fd,
const bool  writable = false 
)

Begin using the ELF file.

Parameters
nameThe full name of the file.
fdThe file descriptor to read or write the file.
writableThe file is writeable. The default is false.
void rld::elf::file::begin ( const std::string &  name,
file archive,
off_t  offset 
)

Begin using the ELF file in an archive.

Parameters
nameThe full name of the file.
archiveThe file that is the archive.
offsetThe offset of the ELF file in the archive.
void rld::elf::file::clear_relocations ( )

Clear the relocation records.

unsigned int rld::elf::file::data_type ( ) const

Get the data type, ie LSB or MSB.

void rld::elf::file::end ( )

End using the ELF file.

elf * rld::elf::file::get_elf ( )

Get the ELF reference.

section & rld::elf::file::get_section ( int  index)

Return the section with given index.

Parameters
indexThe section's index to look for.
Return values
sectionThe section matching the index.
void rld::elf::file::get_sections ( sections filtered_secs,
unsigned int  type 
)

Get a filtered container of the sections. The key is the section type. If the sections are not loaded they are loaded. If the type is 0 all sections are returned.

Parameters
filtered_secsThe container the copy of the filtered sections are placed in.
typeThe type of sections to filter on. If 0 all sections are matched.
std::string rld::elf::file::get_string ( int  section,
size_t  offset 
)

Get the string from the specified section at the requested offset.

Parameters
sectionThe section to search for the string.
offsetThe offset in the string section.
Returns
std::string The string.
std::string rld::elf::file::get_string ( size_t  offset)

Get the string from the ELF header declared string section at the requested offset.

Parameters
offsetThe offset in the string section.
Returns
std::string The string.
const symbols::symbol & rld::elf::file::get_symbol ( const int  index) const

Get the symbol by index in the symtabl section.

void rld::elf::file::get_symbols ( rld::symbols::pointers filtered_syms,
bool  unresolved = false,
bool  local = false,
bool  weak = true,
bool  global = true 
)

Get a filtered container of symbols given the various types. If the symbols are not loaded they are loaded.

Parameters
filtered_symsThe filtered symbols found in the file. This is a container of pointers.
unresolvedReturn unresolved symbols.
localReturn local symbols.
weakReturn weak symbols.
globalReturn global symbols.
bool rld::elf::file::is_archive ( ) const

Is the file an archive format file ?

bool rld::elf::file::is_executable ( ) const

Is the file an executable ?

bool rld::elf::file::is_relocatable ( ) const

Is the file relocatable ?

bool rld::elf::file::is_writable ( ) const

Is the file writable ?

void rld::elf::file::load_header ( )

Load the header. Done automatically.

void rld::elf::file::load_relocations ( )

Load the relocation records.

void rld::elf::file::load_sections ( )

Load the sections.

void rld::elf::file::load_symbols ( )

Load the symbols.

unsigned int rld::elf::file::machinetype ( ) const

Get the machine type.

const std::string & rld::elf::file::name ( ) const

Get the name of the file.

unsigned int rld::elf::file::object_class ( ) const

Get the class of the object file.

int rld::elf::file::section_count ( ) const

The number of sections in the file.

void rld::elf::file::set_header ( elf_half  type,
int  class_,
elf_half  machinetype,
unsigned char  datatype 
)

Set the ELF header. Must be writable.

The classes are: ELFCLASSNONE This class is invalid. ELFCLASS32 This defines the 32-bit architecture. It sup- ports machines with files and virtual address spa- ces up to 4 Gigabytes. ELFCLASS64 This defines the 64-bit architecture.

The types are: ET_NONE An unknown type. ET_REL A relocatable file. ET_EXEC An executable file. ET_DYN A shared object. ET_CORE A core file.

The machine types are: TDB

The datatypes are: ELFDATA2LSB Two's complement, little-endian. ELFDATA2MSB Two's complement, big-endian.

Parameters
typeThe type of ELF file, ie executable, relocatable etc.
class_The files ELF class.
machinetypeThe type of machine code present in the ELF file.
datatypeThe data type, ie LSB or MSB.
int rld::elf::file::strings_section ( ) const

Return the index of the string section.

unsigned int rld::elf::file::type ( ) const

Get the type of ELF file.

void rld::elf::file::write ( )

Write the ELF file creating it if it is writable. You should have added the sections and the data segment descriptors to the sections before calling write.


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