OpenASIP 2.2
Loading...
Searching...
No Matches
Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
TPEF::TPEFRelocSectionWriter Class Reference

#include <TPEFRelocSectionWriter.hh>

Inheritance diagram for TPEF::TPEFRelocSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFRelocSectionWriter:
Collaboration graph

Protected Member Functions

 TPEFRelocSectionWriter ()
 
virtual ~TPEFRelocSectionWriter ()
 
virtual Section::SectionType type () const
 
virtual void actualWriteData (BinaryStream &stream, const Section *section) const
 
virtual Word elementSize (const Section *section) const
 
virtual void writeInfo (BinaryStream &stream, const Section *sect) const
 
- Protected Member Functions inherited from TPEF::TPEFSectionWriter
 TPEFSectionWriter ()
 
virtual ~TPEFSectionWriter ()
 
virtual const BinaryWriterparent () const
 
virtual void actualWriteHeader (BinaryStream &stream, const Section *sect) const
 
virtual void createKeys (const Section *sect) const
 
virtual void writeSize (BinaryStream &stream, const Section *sect) const
 
virtual SectionId getSectionId () const
 
- Protected Member Functions inherited from TPEF::SectionWriter
 SectionWriter ()
 
virtual ~SectionWriter ()
 
virtual void finalize (BinaryStream &stream, Section *section) const
 

Private Member Functions

 TPEFRelocSectionWriter (const TPEFRelocSectionWriter &)
 Copying not allowed.
 
TPEFRelocSectionWriter operator= (const TPEFRelocSectionWriter &)
 Assignment not allowed.
 

Static Private Attributes

static const TPEFRelocSectionWriter instance_
 An unique instance of class.
 
static const Word elementSize_ = 12
 The fixed size of reloc element.
 

Additional Inherited Members

- Static Public Member Functions inherited from TPEF::SectionWriter
static void writeHeader (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void writeData (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void finalizeBinary (BinaryStream &stream, const Binary *binaryToFinalize, const BinaryWriter *writer)
 
- Static Protected Member Functions inherited from TPEF::SectionWriter
static void registerSectionWriter (const SectionWriter *sWriter)
 
static SectionId getUniqueSectionId ()
 

Detailed Description

Writes TPEF relocation section to stream.

Definition at line 47 of file TPEFRelocSectionWriter.hh.

Constructor & Destructor Documentation

◆ TPEFRelocSectionWriter() [1/2]

TPEF::TPEFRelocSectionWriter::TPEFRelocSectionWriter ( )
protected

Construction.

Registers itself to SectionWriter.

Definition at line 69 of file TPEFRelocSectionWriter.cc.

71}
static void registerSectionWriter(const SectionWriter *sWriter)

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ ~TPEFRelocSectionWriter()

TPEF::TPEFRelocSectionWriter::~TPEFRelocSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 76 of file TPEFRelocSectionWriter.cc.

76 {
77}

◆ TPEFRelocSectionWriter() [2/2]

TPEF::TPEFRelocSectionWriter::TPEFRelocSectionWriter ( const TPEFRelocSectionWriter )
private

Copying not allowed.

Member Function Documentation

◆ actualWriteData()

void TPEF::TPEFRelocSectionWriter::actualWriteData ( BinaryStream stream,
const Section section 
) const
protectedvirtual

Writes relocation section in to stream.

Parameters
streamThe stream where to write.
sectionThe section to be written.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 96 of file TPEFRelocSectionWriter.cc.

98 {
99
100 FileOffset startOffset = stream.writePosition();
101
102 // file offset to data of section
104 FileOffsetKey(startOffset), section->element(0));
105
106 const RelocSection *rSection =
107 dynamic_cast<const RelocSection*>(section);
108 assert(rSection != NULL);
109
110
111 for (Word i = 0; i < section->elementCount(); i++) {
112 RelocElement* rElem =
113 dynamic_cast<RelocElement*>(section->element(i));
114 assert(rElem != NULL);
115
116 // r_offset
117 if (rElem->location() != NULL) {
118 SectionOffsetReplacer sReplacer(rElem->location());
119 sReplacer.resolve();
120 } else {
121 bool locationOfRelocationMustBeSet = false;
122 assert(locationOfRelocationMustBeSet);
123 }
124
125 // r_symbol
126 if (rElem->symbol() != NULL) {
127 SectionIndexReplacer indexReplacer(rElem->symbol(), sizeof(Word));
128 indexReplacer.resolve();
129 } else {
130 bool symbolFieldOfRelocationMustBeSet = false;
131 assert(symbolFieldOfRelocationMustBeSet);
132 }
133
134 // r_type
135 Byte rType = 0;
136
137 // chunked bit on if necessary.
138 if (rElem->chunked()) {
139 rType = rType | TPEFHeaders::STF_CHUNK;
140 }
141
142 // and relocation type
143 rType = rType | static_cast<Byte>(rElem->type());
144
145 stream.writeByte(rType);
146
147 // r_asp
148 SectionIndexReplacer indexReplacer(rElem->aSpace(), sizeof(Byte));
149 indexReplacer.resolve();
150
151 // r_size bit width of the value of element referred by location
152 stream.writeByte(rElem->size());
153
154 // r_bitpos for chunked relocations
155 stream.writeByte(rElem->bitOffset());
156 }
157
159 stream.writePosition() - startOffset);
160}
#define assert(condition)
unsigned char Byte
Definition BaseType.hh:116
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
static void setSize(const SafePointable *obj, Word size)
@ STF_CHUNK
Relocation applied to chunk(1) or complete address(0).
Word FileOffset
Type for storing absolute file offsets.

References TPEF::ReferenceManager::SafePointer::addObjectReference(), TPEF::RelocElement::aSpace(), assert, TPEF::RelocElement::bitOffset(), TPEF::RelocElement::chunked(), TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::RelocElement::location(), TPEF::ValueReplacer::resolve(), TPEF::SectionSizeReplacer::setSize(), TPEF::RelocElement::size(), TPEF::TPEFHeaders::STF_CHUNK, TPEF::RelocElement::symbol(), TPEF::RelocElement::type(), TPEF::BinaryStream::writeByte(), and TPEF::BinaryStream::writePosition().

Here is the call graph for this function:

◆ elementSize()

Word TPEF::TPEFRelocSectionWriter::elementSize ( const Section section) const
protectedvirtual

Returns size of element.

Parameters
sectionSection that is written.
Returns
Size of element of this section.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 169 of file TPEFRelocSectionWriter.cc.

169 {
170 return elementSize_;
171}
static const Word elementSize_
The fixed size of reloc element.

References elementSize_.

◆ operator=()

TPEFRelocSectionWriter TPEF::TPEFRelocSectionWriter::operator= ( const TPEFRelocSectionWriter )
private

Assignment not allowed.

◆ type()

Section::SectionType TPEF::TPEFRelocSectionWriter::type ( ) const
protectedvirtual

Returns the type of the section this writer can write.

Returns
The type of section this writer can write.

Implements TPEF::TPEFSectionWriter.

Definition at line 85 of file TPEFRelocSectionWriter.cc.

85 {
86 return Section::ST_RELOC;
87}
@ ST_RELOC
Relocation section.
Definition Section.hh:74

References TPEF::Section::ST_RELOC.

◆ writeInfo()

void TPEF::TPEFRelocSectionWriter::writeInfo ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes Info field of section header.

Parameters
streamThe stream where to write.
sectSection to write.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 180 of file TPEFRelocSectionWriter.cc.

181 {
182
183 const Section* refSection =
184 dynamic_cast<const RelocSection*>(sect)->referencedSection();
185
186 SectionIdReplacer idReplacer(refSection);
187 idReplacer.resolve();
188
189 stream.writeHalfWord(0);
190}

References TPEF::ValueReplacer::resolve(), and TPEF::BinaryStream::writeHalfWord().

Here is the call graph for this function:

Member Data Documentation

◆ elementSize_

const Word TPEF::TPEFRelocSectionWriter::elementSize_ = 12
staticprivate

The fixed size of reloc element.

Definition at line 71 of file TPEFRelocSectionWriter.hh.

Referenced by elementSize().

◆ instance_

const TPEFRelocSectionWriter TPEF::TPEFRelocSectionWriter::instance_
staticprivate

An unique instance of class.

Definition at line 69 of file TPEFRelocSectionWriter.hh.


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