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

#include <rld-elf.h>

Public Member Functions

 section (file &file_, int index_, const std::string &name, elf_word type, elf_xword alignment, elf_xword flags, elf_addr addr, elf_off offset, elf_xword size, elf_word link=0, elf_word info=0, elf_xword entry_size=0)
 
 section (file &file_, int index)
 
 section (const section &orig)
 
 section ()
 
void add_data (elf_type type, elf_xword alignment, elf_xword size, void *buffer=0, elf_off offset=0)
 
int index () const
 
const std::string & name () const
 
elf_datadata ()
 
elf_word type () const
 
elf_xword flags () const
 
elf_addr address () const
 
elf_xword alignment () const
 
elf_off offset () const
 
elf_word link () const
 
elf_word info () const
 
elf_xword size () const
 
elf_xword entry_size () const
 
int entries () const
 
bool get_reloc_type () const
 
void set_name (unsigned int index)
 
void set_reloc_type (bool rela)
 
void add (const relocation &reloc)
 
const relocationsget_relocations () const
 

Detailed Description

An ELF Section. The current implementation only supports a single data descriptor with a section.

Constructor & Destructor Documentation

rld::elf::section::section ( file file_,
int  index_,
const std::string &  name,
elf_word  type,
elf_xword  alignment,
elf_xword  flags,
elf_addr  addr,
elf_off  offset,
elf_xword  size,
elf_word  link = 0,
elf_word  info = 0,
elf_xword  entry_size = 0 
)

Construct the section getting the details from the ELF file given the section index.

The section types are (from elf(3)):

Section Type Library Type Description


SHT_DYNAMIC ELF_T_DYN `.dynamic' section entries. SHT_DYNSYM ELF_T_SYM Symbols for dynamic linking. SHT_FINI_ARRAY ELF_T_ADDR Termination function pointers. SHT_GROUP ELF_T_WORD Section group marker. SHT_HASH ELF_T_HASH Symbol hashes. SHT_INIT_ARRAY ELF_T_ADDR Initialization function pointers. SHT_NOBITS ELF_T_BYTE Empty sections. See elf(5). SHT_NOTE ELF_T_NOTE ELF note records. SHT_PREINIT_ARRAY ELF_T_ADDR Pre-initialization function pointers. SHT_PROGBITS ELF_T_BYTE Machine code. SHT_REL ELF_T_REL ELF relocation records. SHT_RELA ELF_T_RELA Relocation records with addends. SHT_STRTAB ELF_T_BYTE String tables. SHT_SYMTAB ELF_T_SYM Symbol tables. SHT_SYMTAB_SHNDX ELF_T_WORD Used with extended section numbering. SHT_GNU_verdef ELF_T_VDEF Symbol version definitions. SHT_GNU_verneed ELF_T_VNEED Symbol versioning requirements. SHT_GNU_versym ELF_T_HALF Version symbols. SHT_SUNW_move ELF_T_MOVE ELF move records. SHT_SUNW_syminfo ELF_T_SYMINFO Additional symbol flags.

Parameters
file_The ELF file this section is part of.
index_The section's index.
nameThe section's name.
typeThe section's type.
alignmentThe section's alignment.
flagsThe section's flags.
addrThe section's in-memory address.
offsetThe section's offset in the file.
sizeThe section's file in bytes.
linkThe section's header table link.
infoThe section's extra information.
entry_sizeThe section's entry size.
rld::elf::section::section ( file file_,
int  index 
)

Construct the section given the details. The ELF file must be writable.

Parameters
file_The ELF file this section is part of.
indexThe section's index in the ELF file.
rld::elf::section::section ( const section orig)

Copy constructor.

rld::elf::section::section ( )

Default constructor.

Member Function Documentation

void rld::elf::section::add ( const relocation reloc)

Add a relocation.

Parameters
relocThe relocation record to add.
void rld::elf::section::add_data ( elf_type  type,
elf_xword  alignment,
elf_xword  size,
void *  buffer = 0,
elf_off  offset = 0 
)

Add a data segment descriptor to the section if the file is writable.

These are following data types (from elf(3)):

ELF_T_ADDR Machine addresses. ELF_T_BYTE Byte data. The library will not attempt to translate byte data. ELF_T_CAP Software and hardware capability records. ELF_T_DYN Records used in a section of type SHT_DYNAMIC. ELF_T_EHDR ELF executable header. ELF_T_HALF 16-bit unsigned words. ELF_T_LWORD 64 bit unsigned words. ELF_T_MOVE ELF Move records. ELF_T_NOTE ELF Note structures. ELF_T_OFF File offsets. ELF_T_PHDR ELF program header table entries. ELF_T_REL ELF relocation entries. ELF_T_RELA ELF relocation entries with addends. ELF_T_SHDR ELF section header entries. ELF_T_SWORD Signed 32-bit words. ELF_T_SXWORD Signed 64-bit words. ELF_T_SYMINFO ELF symbol information. ELF_T_SYM ELF symbol table entries. ELF_T_VDEF Symbol version definition records. ELF_T_VNEED Symbol version requirement records. ELF_T_WORD Unsigned 32-bit words. ELF_T_XWORD Unsigned 64-bit words.

Parameters
typeThe type of data in the segment.
alignmentThe in-file alignment of the data. Must be a power of 2.
sizeThe number of bytes in this data descriptor.
bufferThe data in memory.
offsetThe offset within the containing section. Can be computed.
elf_addr rld::elf::section::address ( ) const

In-memory address of the section.

elf_xword rld::elf::section::alignment ( ) const

Alignment constraint.

elf_data * rld::elf::section::data ( )

The section's data.

int rld::elf::section::entries ( ) const

Number of entries.

elf_xword rld::elf::section::entry_size ( ) const

Size of the entries in the section.

elf_xword rld::elf::section::flags ( ) const

The section flags.

bool rld::elf::section::get_reloc_type ( ) const

Return true if the relocation record have an addend field.

Return values
trueThe relocation record have the addend field.
const relocations & rld::elf::section::get_relocations ( ) const

Get the relocations.

int rld::elf::section::index ( ) const

The section's index in the ELF file.

Returns
int The section number.
elf_word rld::elf::section::info ( ) const

Extra information.

elf_word rld::elf::section::link ( ) const

The header table link.

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

The name of the section.

Returns
const std::string& The section's name.
elf_off rld::elf::section::offset ( ) const

The file offset of the section.

void rld::elf::section::set_name ( unsigned int  index)

Set the name index if writable. This is normally done automatically when adding the section to the file.

void rld::elf::section::set_reloc_type ( bool  rela)

Set the type of relocation records.

Parameters
relaIf true the records are rela type.
elf_xword rld::elf::section::size ( ) const

Size of the section.

elf_word rld::elf::section::type ( ) const

Get the type of the section.


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