#include <rld-elf.h>
|
| 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) |
|
section & | get_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::symbol & | get_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) |
|
elf * | get_elf () |
|
const std::string & | name () const |
|
bool | is_writable () const |
|
rld::elf::file::~file |
( |
| ) |
|
Destruct the ELF file object.
void rld::elf::file::add |
( |
section & |
sec | ) |
|
Add a section to the ELF file if writable.
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
-
name | The full name of the file. |
fd | The file descriptor to read or write the file. |
writable | The 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
-
name | The full name of the file. |
archive | The file that is the archive. |
offset | The 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 |
( |
| ) |
|
elf * rld::elf::file::get_elf |
( |
| ) |
|
section & rld::elf::file::get_section |
( |
int |
index | ) |
|
Return the section with given index.
- Parameters
-
index | The section's index to look for. |
- Return values
-
section | The 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_secs | The container the copy of the filtered sections are placed in. |
type | The 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
-
section | The section to search for the string. |
offset | The 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
-
offset | The 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_syms | The filtered symbols found in the file. This is a container of pointers. |
unresolved | Return unresolved symbols. |
local | Return local symbols. |
weak | Return weak symbols. |
global | Return 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 |
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 |
( |
| ) |
|
void rld::elf::file::load_symbols |
( |
| ) |
|
unsigned int rld::elf::file::machinetype |
( |
| ) |
const |
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
-
type | The type of ELF file, ie executable, relocatable etc. |
class_ | The files ELF class. |
machinetype | The type of machine code present in the ELF file. |
datatype | The 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:
- /Users/chris/Development/rtems/src/apps/rtl-host.chrisj/rld-elf.h
- /Users/chris/Development/rtems/src/apps/rtl-host.chrisj/rld-elf.cpp