OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TPEF::Section Class Referenceabstract

#include <Section.hh>

Inheritance diagram for TPEF::Section:
Inheritance graph
Collaboration diagram for TPEF::Section:
Collaboration graph

Public Types

enum  SectionType {
  ST_NULL = 0x00 , ST_STRTAB = 0x01 , ST_SYMTAB = 0x02 , ST_DEBUG = 0x03 ,
  ST_RELOC = 0x04 , ST_LINENO = 0x05 , ST_NOTE = 0x06 , ST_ADDRSP = 0x07 ,
  ST_MR = 0x0A , ST_CODE = 0x81 , ST_DATA = 0x82 , ST_UDATA = 0x83 ,
  ST_LEDATA = 0x84 , ST_DUMMY = 0xff
}
 
enum  SectionFlag { SF_VLEN = 0x40 , SF_NOBITS = 0x80 }
 

Public Member Functions

virtual SectionType type () const =0
 Returns SectioType of actual section instance.
 
virtual ~Section ()
 
virtual bool isChunkable () const
 
virtual Chunkchunk (SectionOffset offset) const
 
bool isProgramSection () const
 
bool isAuxSection () const
 
virtual void addElement (SectionElement *element)
 
virtual void setElement (Word index, SectionElement *element)
 
SectionElementelement (Word index) const
 
Word elementCount () const
 
void setFlagNoBits ()
 
void unsetFlagNoBits ()
 
bool noBits () const
 
bool vLen () const
 
Byte flags () const
 
void setFlags (Byte flagByte)
 
void setStartingAddress (AddressImage address)
 
AddressImage startingAddress () const
 
void setLink (const ReferenceManager::SafePointer *aLink)
 
void setLink (Section *aLink)
 
Sectionlink () const
 
void setASpace (const ReferenceManager::SafePointer *addrSpace)
 
void setASpace (ASpaceElement *addrSpace)
 
ASpaceElementaSpace () const
 
void setName (const ReferenceManager::SafePointer *sectionName)
 
void setName (Chunk *sectionName)
 
Chunkname () const
 
virtual bool isDataSection () const
 
virtual bool isCodeSection () const
 
- Public Member Functions inherited from TPEF::SafePointable
virtual ~SafePointable ()
 

Static Public Member Functions

static SectioncreateSection (SectionType type)
 
static bool isProgramSection (SectionType type)
 

Protected Member Functions

virtual Sectionclone () const =0
 Creates clone of instance.
 
 Section ()
 
void setFlagVLen ()
 
void unsetFlagVLen ()
 
- Protected Member Functions inherited from TPEF::SafePointable
 SafePointable ()
 

Static Protected Member Functions

static void registerSection (const Section *section)
 

Private Types

typedef std::map< SectionType, const Section * > SectionPrototypeMap
 Type of map that contains section prototypes.
 

Private Member Functions

 Section (const Section &)
 
bool flag (SectionFlag aFlag) const
 
void setFlag (SectionFlag aFlag)
 
void unsetFlag (SectionFlag aFlag)
 

Private Attributes

std::vector< SectionElement * > elements_
 Contain elements.
 
const ReferenceManager::SafePointerlink_
 TPEF link field.
 
const ReferenceManager::SafePointeraSpace_
 TPEF address space field.
 
const ReferenceManager::SafePointername_
 TPEF name field.
 
Byte flags_
 TPEF flag byte.
 
Word startingAddress_
 TPEF startin memory address field.
 

Static Private Attributes

static SectionPrototypeMapprototypes_ = NULL
 Container for registere section prototypes.
 
static const Byte PROGRAM_SECTION_MASK = 0x80
 Mask for checking if section is auxiliary or program section.
 

Detailed Description

Abstract base class for concrete sections.

Stores section header data and handles registration requests and book keeping for concrete sections. See prototype design pattern.

Definition at line 64 of file Section.hh.

Member Typedef Documentation

◆ SectionPrototypeMap

typedef std::map<SectionType, const Section*> TPEF::Section::SectionPrototypeMap
private

Type of map that contains section prototypes.

Definition at line 165 of file Section.hh.

Member Enumeration Documentation

◆ SectionFlag

TPEF section flags.

Enumerator
SF_VLEN 

Contains elements with variable length.

SF_NOBITS 

Not initialized or not stored in this file.

Definition at line 89 of file Section.hh.

89 {
90 SF_VLEN = 0x40, ///< Contains elements with variable length.
91 SF_NOBITS = 0x80 ///< Not initialized or not stored in this file.
92 };
@ SF_VLEN
Contains elements with variable length.
Definition Section.hh:90
@ SF_NOBITS
Not initialized or not stored in this file.
Definition Section.hh:91

◆ SectionType

TPEF section type ids.

Enumerator
ST_NULL 

NULL Section.

ST_STRTAB 

String table.

ST_SYMTAB 

Symbol table.

ST_DEBUG 

Debug section.

ST_RELOC 

Relocation section.

ST_LINENO 

Line number section.

ST_NOTE 

Note section.

ST_ADDRSP 

Address space section.

ST_MR 

Machine resources section.

ST_CODE 

Text section.

ST_DATA 

Initialized data section.

ST_UDATA 

Uninitialized data section.

ST_LEDATA 

Initialized little endian data section.

ST_DUMMY 

Dummy section type for testing purposes.

Definition at line 69 of file Section.hh.

69 {
70 ST_NULL = 0x00, ///< NULL Section
71 ST_STRTAB = 0x01, ///< String table.
72 ST_SYMTAB = 0x02, ///< Symbol table.
73 ST_DEBUG = 0x03, ///< Debug section.
74 ST_RELOC = 0x04, ///< Relocation section.
75 ST_LINENO = 0x05, ///< Line number section.
76 ST_NOTE = 0x06, ///< Note section.
77 ST_ADDRSP = 0x07, ///< Address space section.
78 ST_MR = 0x0A, ///< Machine resources section.
79 ST_CODE = 0x81, ///< Text section.
80 ST_DATA = 0x82, ///< Initialized data section.
81 ST_UDATA = 0x83, ///< Uninitialized data section.
82 ST_LEDATA = 0x84, ///< Initialized little endian data section.
83 ST_DUMMY = 0xff ///< Dummy section type for testing purposes.
84 };
@ ST_SYMTAB
Symbol table.
Definition Section.hh:72
@ ST_DATA
Initialized data section.
Definition Section.hh:80
@ ST_STRTAB
String table.
Definition Section.hh:71
@ ST_ADDRSP
Address space section.
Definition Section.hh:77
@ ST_DUMMY
Dummy section type for testing purposes.
Definition Section.hh:83
@ ST_UDATA
Uninitialized data section.
Definition Section.hh:81
@ ST_LEDATA
Initialized little endian data section.
Definition Section.hh:82
@ ST_LINENO
Line number section.
Definition Section.hh:75
@ ST_NULL
NULL Section.
Definition Section.hh:70
@ ST_CODE
Text section.
Definition Section.hh:79
@ ST_RELOC
Relocation section.
Definition Section.hh:74
@ ST_MR
Machine resources section.
Definition Section.hh:78
@ ST_NOTE
Note section.
Definition Section.hh:76
@ ST_DEBUG
Debug section.
Definition Section.hh:73

Constructor & Destructor Documentation

◆ ~Section()

TPEF::Section::~Section ( )
virtual

Destructor.

Definition at line 76 of file Section.cc.

76 {
77 while (elements_.size() != 0) {
78 delete elements_[elements_.size() - 1];
79 elements_.pop_back();
80 }
81}
std::vector< SectionElement * > elements_
Contain elements.
Definition Section.hh:170

References elements_.

◆ Section() [1/2]

TPEF::Section::Section ( )
protected

Constructor.

Definition at line 64 of file Section.cc.

64 :
69 flags_(0),
71}
static const SafePointer null
The default SafePointer that is used in null references.
const ReferenceManager::SafePointer * name_
TPEF name field.
Definition Section.hh:177
const ReferenceManager::SafePointer * aSpace_
TPEF address space field.
Definition Section.hh:175
Byte flags_
TPEF flag byte.
Definition Section.hh:179
const ReferenceManager::SafePointer * link_
TPEF link field.
Definition Section.hh:173
Word startingAddress_
TPEF startin memory address field.
Definition Section.hh:181

◆ Section() [2/2]

TPEF::Section::Section ( const Section )
private

Member Function Documentation

◆ addElement()

void TPEF::Section::addElement ( SectionElement element)
virtual

Adds an element to section.

Parameters
elementElement that is added to section.

Reimplemented in TPEF::CodeSection.

Definition at line 133 of file Section.cc.

133 {
134 assert(element != NULL);
135 elements_.push_back(element);
136}
#define assert(condition)
SectionElement * element(Word index) const

References assert, element(), and elements_.

Referenced by TPEF::CodeSection::addElement(), MachineResourceManager::addResourceElement(), TTAProgram::TPEFResourceUpdater::bus(), MachineResourceManager::codeAddressSpace(), TTAProgram::ProgramWriter::createASpaceElement(), TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createRelocSections(), LabelManager::finalize(), TPEF::AOutSymbolSectionReader::finalize(), MachineResourceManager::findDataAddressSpace(), TTAProgram::TPEFResourceUpdater::functionUnit(), TTAProgram::TPEFResourceUpdater::functionUnitPort(), TTAProgram::TPEFResourceUpdater::immediateUnit(), TPEF::AOutSymbolSectionReader::initializeSymbol(), MachineResourceManager::initResourceSection(), TTAProgram::TPEFResourceUpdater::operand(), TPEF::AOutReader::readData(), TPEF::AOutRelocationSectionReader::readData(), TPEF::AOutSymbolSectionReader::readData(), TPEF::AOutTextSectionReader::readData(), TPEF::TPEFASpaceSectionReader::readData(), TPEF::TPEFDebugSectionReader::readData(), TPEF::TPEFLineNumSectionReader::readData(), TPEF::TPEFRelocSectionReader::readData(), TPEF::TPEFResourceSectionReader::readData(), TPEF::TPEFSymbolSectionReader::readData(), TTAProgram::TPEFResourceUpdater::registerFile(), MachineResourceManager::undefinedAddressSpace(), and LabelManager::writeProcedureSymbols().

Here is the call graph for this function:

◆ aSpace()

ASpaceElement * TPEF::Section::aSpace ( ) const

◆ chunk()

Chunk * TPEF::Section::chunk ( SectionOffset  offset) const
virtual

Returns a chunk that has offset to a data of section.

Parameters
offsetOffset to a data that is wanted to be referenced.
Returns
Chunk for raw data section.
Exceptions
NotChunkableIf Section is not derived from RawSection.

Reimplemented in TPEF::RawSection.

Definition at line 169 of file Section.cc.

169 {
170 throw NotChunkable(__FILE__, __LINE__, "Section::chunk");
171}

Referenced by TPEF::TPEFStringSectionWriter::actualWriteData(), TPEF::ReferenceManager::SafePointer::resolve(), and TPEF::TPEFSectionWriter::writeBodyStartOffset().

◆ clone()

virtual Section * TPEF::Section::clone ( ) const
protectedpure virtual

◆ createSection()

Section * TPEF::Section::createSection ( SectionType  type)
static

Creates instance of concrete section type.

Parameters
typeType of section instance that is to be created.
Returns
Pointer to newly created section.
Exceptions
InstanceNotFoundIf there is no registered instance for type.

Definition at line 91 of file Section.cc.

91 {
92 if (prototypes_ == NULL ||
94
95 throw InstanceNotFound(
96 __FILE__, __LINE__, __func__,
97 TCEString("No prototype for section type: ") +
98 Conversion::toString(static_cast<int>(type)));
99 }
100
101 Section* section = (*prototypes_)[type]->clone();
102 return section;
103}
#define __func__
static std::string toString(const T &source)
static bool containsKey(const MapType &aMap, const KeyType &aKey)
static SectionPrototypeMap * prototypes_
Container for registere section prototypes.
Definition Section.hh:168
virtual SectionType type() const =0
Returns SectioType of actual section instance.

References __func__, clone(), MapTools::containsKey(), prototypes_, Conversion::toString(), and type().

Referenced by CodeSectionCreator::finalize(), DataSectionCreator::finalize(), MachineResourceManager::initResourceSection(), MachineResourceManager::nullSection(), TPEF::AOutReader::readData(), TPEF::TPEFReader::readData(), MachineResourceManager::stringToChunk(), and MachineResourceManager::undefinedAddressSpace().

Here is the call graph for this function:

◆ element()

SectionElement * TPEF::Section::element ( Word  index) const

◆ elementCount()

Word TPEF::Section::elementCount ( ) const

◆ flag()

bool TPEF::Section::flag ( SectionFlag  aFlag) const
private

◆ flags()

Byte TPEF::Section::flags ( ) const

◆ isAuxSection()

bool TPEF::Section::isAuxSection ( ) const

◆ isChunkable()

bool TPEF::Section::isChunkable ( ) const
virtual

Returns true if section is chunkable.

Returns
True if section is chunkable.

Reimplemented in TPEF::RawSection.

Definition at line 157 of file Section.cc.

157 {
158 return false;
159}

Referenced by TPEFDumper::sectionHeader(), TPEF::TPEFTools::sectionOfElement(), and TPEF::TPEFSectionWriter::writeBodyStartOffset().

◆ isCodeSection()

virtual bool TPEF::Section::isCodeSection ( ) const
inlinevirtual

◆ isDataSection()

virtual bool TPEF::Section::isDataSection ( ) const
inlinevirtual

Reimplemented in TPEF::DataSection.

Definition at line 142 of file Section.hh.

142{ return false; }

Referenced by TTAProgram::ProgramWriter::createDataSections().

◆ isProgramSection() [1/2]

bool TPEF::Section::isProgramSection ( ) const

◆ isProgramSection() [2/2]

static bool TPEF::Section::isProgramSection ( SectionType  type)
static

◆ link()

Section * TPEF::Section::link ( ) const

◆ name()

Chunk * TPEF::Section::name ( ) const

◆ noBits()

bool TPEF::Section::noBits ( ) const

◆ registerSection()

void TPEF::Section::registerSection ( const Section section)
staticprotected

Registers section instance that implements some section type.

Every registered prototype implements one of used sections. These registered sections are used to clone section instances by SectionType.

Parameters
sectionSection instance that will be registered.

Definition at line 114 of file Section.cc.

114 {
115
116 // We can't create prototypes_ map statically, because we don't know
117 //if it is initialized before this method is called.
118 if (prototypes_ == NULL) {
120 }
121
122 assert(!MapTools::containsKey(*prototypes_, section->type()));
123
124 (*prototypes_)[section->type()] = section;
125}
std::map< SectionType, const Section * > SectionPrototypeMap
Type of map that contains section prototypes.
Definition Section.hh:165

References assert, MapTools::containsKey(), prototypes_, and type().

Referenced by TPEF::ASpaceSection::ASpaceSection(), TPEF::CodeSection::CodeSection(), TPEF::DataSection::DataSection(), TPEF::DebugSection::DebugSection(), TPEF::LEDataSection::LEDataSection(), TPEF::LineNumSection::LineNumSection(), TPEF::NullSection::NullSection(), TPEF::RelocSection::RelocSection(), TPEF::ResourceSection::ResourceSection(), TPEF::StringSection::StringSection(), TPEF::SymbolSection::SymbolSection(), and TPEF::UDataSection::UDataSection().

Here is the call graph for this function:

◆ setASpace() [1/2]

void TPEF::Section::setASpace ( ASpaceElement addrSpace)

◆ setASpace() [2/2]

void TPEF::Section::setASpace ( const ReferenceManager::SafePointer addrSpace)

◆ setElement()

void TPEF::Section::setElement ( Word  index,
SectionElement element 
)
virtual

Sets replaces an element in given index with another.

Parameters
indexIndex of element that is replaced.
elementElement that is set to given index.

Reimplemented in TPEF::CodeSection.

Definition at line 145 of file Section.cc.

145 {
146 assert(element != NULL);
147 assert(index < elementCount());
148 elements_[index] = element;
149}
Word elementCount() const

References assert, element(), elementCount(), and elements_.

Referenced by TPEF::AOutSymbolSectionReader::finalize(), and TPEF::CodeSection::setElement().

Here is the call graph for this function:

◆ setFlag()

void TPEF::Section::setFlag ( SectionFlag  aFlag)
private

◆ setFlagNoBits()

void TPEF::Section::setFlagNoBits ( )

◆ setFlags()

void TPEF::Section::setFlags ( Byte  flagByte)

◆ setFlagVLen()

void TPEF::Section::setFlagVLen ( )
protected

◆ setLink() [1/2]

void TPEF::Section::setLink ( const ReferenceManager::SafePointer aLink)

◆ setLink() [2/2]

void TPEF::Section::setLink ( Section aLink)

◆ setName() [1/2]

void TPEF::Section::setName ( Chunk sectionName)

◆ setName() [2/2]

void TPEF::Section::setName ( const ReferenceManager::SafePointer sectionName)

◆ setStartingAddress()

void TPEF::Section::setStartingAddress ( AddressImage  address)

◆ startingAddress()

AddressImage TPEF::Section::startingAddress ( ) const

◆ type()

virtual SectionType TPEF::Section::type ( ) const
pure virtual

◆ unsetFlag()

void TPEF::Section::unsetFlag ( SectionFlag  aFlag)
private

◆ unsetFlagNoBits()

void TPEF::Section::unsetFlagNoBits ( )

◆ unsetFlagVLen()

void TPEF::Section::unsetFlagVLen ( )
protected

◆ vLen()

bool TPEF::Section::vLen ( ) const

Member Data Documentation

◆ aSpace_

const ReferenceManager::SafePointer* TPEF::Section::aSpace_
private

TPEF address space field.

Definition at line 175 of file Section.hh.

◆ elements_

std::vector<SectionElement*> TPEF::Section::elements_
private

Contain elements.

Definition at line 170 of file Section.hh.

Referenced by addElement(), setElement(), and ~Section().

◆ flags_

Byte TPEF::Section::flags_
private

TPEF flag byte.

Definition at line 179 of file Section.hh.

◆ link_

const ReferenceManager::SafePointer* TPEF::Section::link_
private

TPEF link field.

Definition at line 173 of file Section.hh.

◆ name_

const ReferenceManager::SafePointer* TPEF::Section::name_
private

TPEF name field.

Definition at line 177 of file Section.hh.

◆ PROGRAM_SECTION_MASK

const Byte TPEF::Section::PROGRAM_SECTION_MASK = 0x80
staticprivate

Mask for checking if section is auxiliary or program section.

Definition at line 183 of file Section.hh.

◆ prototypes_

Section::SectionPrototypeMap * TPEF::Section::prototypes_ = NULL
staticprivate

Container for registere section prototypes.

Definition at line 168 of file Section.hh.

Referenced by createSection(), and registerSection().

◆ startingAddress_

Word TPEF::Section::startingAddress_
private

TPEF startin memory address field.

Definition at line 181 of file Section.hh.


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