OpenASIP  2.0
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TPEF::AOutSymbolSectionReader Class Reference

#include <AOutSymbolSectionReader.hh>

Inheritance diagram for TPEF::AOutSymbolSectionReader:
Inheritance graph
Collaboration diagram for TPEF::AOutSymbolSectionReader:
Collaboration graph

Classes

struct  CompilationModule
 
struct  StabData
 

Public Member Functions

virtual ~AOutSymbolSectionReader ()
 
- Public Member Functions inherited from TPEF::AOutSectionReader
virtual ~AOutSectionReader ()
 
- Public Member Functions inherited from TPEF::SectionReader
virtual ~SectionReader ()
 

Protected Member Functions

 AOutSymbolSectionReader ()
 
virtual Section::SectionType type () const
 
virtual void finalize (Section *section) const
 
virtual void readData (BinaryStream &stream, Section *section) const
 
- Protected Member Functions inherited from TPEF::AOutSectionReader
 AOutSectionReader ()
 
virtual BinaryReaderparent () const
 
- Protected Member Functions inherited from TPEF::SectionReader
 SectionReader ()
 

Private Member Functions

SymbolElementinitializeSymbol (BinaryStream &stream, SectionOffset sectionOffset, AOutReader *reader) const
 
 AOutSymbolSectionReader (const AOutSymbolSectionReader &)
 Copying not allowed. More...
 
AOutSymbolSectionReaderoperator= (const AOutSymbolSectionReader &)
 Assignment not allowed. More...
 

Private Attributes

std::map< std::string, Word > resolvedResources_
 Resource id:s for strings. More...
 
std::vector< CompilationModuleaddedResources_
 List of compilation modules of a.out. More...
 
std::vector< std::pair< Word, std::string > > annotationes_
 

Static Private Attributes

static const Word DATA_SYMBOL_SIZE = 4
 Data symbol size in bytes. More...
 
static const std::string GCC_MODULE_START_SYMBOL1 = "gcc2_compiled."
 One of the symbols that are used to indicate start of new compilation module in a.out symbol table. More...
 
static const std::string GCC_MODULE_START_SYMBOL2 = "___gnu_compiled_c"
 One of the symbols that are used to indicate start of new compilation module in a.out symbol table. More...
 
static AOutSymbolSectionReader proto_
 Class-wide (unique) prototype instance of AOutSymbolSectionReader registered into SectionReader. More...
 

Additional Inherited Members

- Public Types inherited from TPEF::SectionReader
typedef BinaryReader::Length Length
 
- Static Public Member Functions inherited from TPEF::SectionReader
static void readSection (BinaryStream &stream, Section *section, BinaryReader *reader)
 
static void finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader)
 
- Static Protected Member Functions inherited from TPEF::SectionReader
static const SectionReaderfindSectionReader (const Section::SectionType type, const BinaryReader *bReader)
 
static void registerSectionReader (const SectionReader *sReader)
 

Detailed Description

Reads symbol table section from a.out binary file.

Definition at line 54 of file AOutSymbolSectionReader.hh.

Constructor & Destructor Documentation

◆ ~AOutSymbolSectionReader()

TPEF::AOutSymbolSectionReader::~AOutSymbolSectionReader ( )
virtual

Destructor.

Definition at line 86 of file AOutSymbolSectionReader.cc.

86  {
87 }

◆ AOutSymbolSectionReader() [1/2]

TPEF::AOutSymbolSectionReader::AOutSymbolSectionReader ( )
protected

Constructor.

Registers itself to SectionReader.

Definition at line 79 of file AOutSymbolSectionReader.cc.

References TPEF::SectionReader::registerSectionReader().

Here is the call graph for this function:

◆ AOutSymbolSectionReader() [2/2]

TPEF::AOutSymbolSectionReader::AOutSymbolSectionReader ( const AOutSymbolSectionReader )
private

Copying not allowed.

Member Function Documentation

◆ finalize()

void TPEF::AOutSymbolSectionReader::finalize ( Section section) const
protectedvirtual

Finalizer method for AOut symbol sections.

Removes reserved gcc code symbols and converts compilation unit code label to file symbol.

Fixes resource references of special operations to use same id in all compilation units.

Adds annotationes to needed moves.

Parameters
sectionSection to finalize.

Reimplemented from TPEF::SectionReader.

Definition at line 433 of file AOutSymbolSectionReader.cc.

433  {
434 
435  StringSection *strTab = dynamic_cast<StringSection*>(section->link());
436 
437  NullSection* nullSection =
438  dynamic_cast<AOutReader*>(parent())->nullSection();
439 
440  assert(nullSection);
441 
442  // make file symbols to tpef
443  for (Word i = 0; i < section->elementCount(); i++) {
444 
445  SymbolElement *sym =
446  dynamic_cast<SymbolElement*>(section->element(i));
447 
448  if (sym->type() == SymbolElement::STT_CODE) {
449 
450  std::string symName = strTab->chunk2String(sym->name());
451 
452  // if read a.out is linked and compilation unit's start
453  // symbol is found (i == 1 and GCC_MODULE_START_SYMBOL1 is
454  // found it means that first read symbol from a.out was
455  // GCC_MODULE_START_SYMBOL1. In linked a.out there is always
456  // symbol for each compilation module before
457  // GCC_MODULE_START_SYMBOL1)
458 
459 
460  if (i > 1 && symName == GCC_MODULE_START_SYMBOL1) {
461 
462  SymbolElement *prevSymbol =
463  dynamic_cast<SymbolElement*>(section->element(i - 1));
464 
465  // previous symbol can be either code symbol or no type,
466  // if there is no instructions in compilation modulex
467  assert(prevSymbol->type() == SymbolElement::STT_CODE ||
468  prevSymbol->type() == SymbolElement::STT_NOTYPE);
469 
470  FileSymElement *newFileSym = new FileSymElement();
471  newFileSym->setName(prevSymbol->name());
472 
473  newFileSym->setSection(nullSection);
474 
475  CodeSymElement *codeSym =
476  dynamic_cast<CodeSymElement*>(prevSymbol);
477 
478  if (codeSym != NULL) {
479  // TODO: set value and section to be same that in code
480  // section newFileSym->setSection(codeSym->section());
481  // newFileSym->setValue();
482  }
483 
484  section->setElement(i - 1, newFileSym);
485 
486  // replace all references to prevSymbol with
487  // newFileSym reference.
488  SafePointer::replaceAllReferences(newFileSym, prevSymbol);
489  delete prevSymbol;
490  prevSymbol = NULL;
491  }
492 
493  if (symName == GCC_MODULE_START_SYMBOL1 ||
494  symName == GCC_MODULE_START_SYMBOL2) {
495 
496  NoTypeSymElement *replacingSymbol = new NoTypeSymElement();
497  replacingSymbol->setName(sym->name());
498  replacingSymbol->setSection(nullSection);
499 
500  section->setElement(i, replacingSymbol);
501 
502  // replace all references to sym with replacing symbol
503  // reference
504  SafePointer::replaceAllReferences(replacingSymbol, sym);
505  delete sym;
506  sym = NULL;
507 
508  } else {
509  // create corresponding STT_PROCEDURE symbol for each code
510  // symbol
511  ProcedSymElement *newSym = new ProcedSymElement();
512  CodeSymElement *codeSym = dynamic_cast<CodeSymElement*>(sym);
513  assert(codeSym != NULL);
514 
515  newSym->setAbsolute(codeSym->absolute());
516  newSym->setBinding(SymbolElement::STB_LOCAL);
517  newSym->setName(codeSym->name());
518  newSym->setSection(codeSym->section());
519  newSym->setReference(codeSym->reference());
520  newSym->setSize(codeSym->size());
521 
522  section->addElement(newSym);
523  }
524  }
525  }
526 
527  // fix operand references from code section with information gathered from
528  // symbol table.
529 
530  CodeSection* textSection =
531  dynamic_cast<AOutReader*>(parent())->textSection();
532 
533  for (unsigned int i = 0; i < addedResources_.size(); i++) {
534  CompilationModule& module = addedResources_[i];
535 
536  // resolve address slice to convert...
537  Word lastAddress = textSection->instructionCount();
538 
539  if (i < addedResources_.size() - 1) {
540  lastAddress = addedResources_[i+1].startAddress_;
541  }
542 
543  // fix the stuff...
544  for (unsigned int j = module.startAddress_; j < lastAddress; j++) {
545 
546  // get move to check
547  InstructionElement* instr = &textSection->instruction(j);
548 
549  MoveElement* move = NULL;
550 
551  // check only move's
552  if (instr->isImmediate()) {
553  Word sectionIndex = textSection->instructionToSectionIndex(j);
554  instr = dynamic_cast<InstructionElement*>(
555  textSection->element(sectionIndex + 1));
556  }
557 
558  move = dynamic_cast<MoveElement*>(instr);
559 
560  // if source is universal FU port, replace if updating is needed
561  if (move->sourceType() == MoveElement::MF_UNIT &&
562  move->sourceUnit() == ResourceElement::UNIVERSAL_FU &&
564  module.resources_, move->sourceIndex())) {
565 
566  move->setSourceIndex(module.resources_[move->sourceIndex()]);
567  }
568 
569  // if destination is universal FU port,
570  // replace if updating is needed
571  if (move->destinationType() == MoveElement::MF_UNIT &&
572  move->destinationUnit() == ResourceElement::UNIVERSAL_FU &&
574  module.resources_, move->destinationIndex())) {
575 
576  move->setDestinationIndex(
577  module.resources_[move->destinationIndex()]);
578  }
579  }
580 
581  }
582 
583  // Add annotations to instruction elements
584  for (Word i = 0; i < annotationes_.size(); i++) {
585 
586  InstructionElement* instr = dynamic_cast<InstructionElement*>(
587  textSection->element(annotationes_[i].first));
588 
589  std::string annString = annotationes_[i].second;
590 
591  // first 10 letters are annotation ID
592  if (annString.at(10) != ':') {
593  throw IllegalProgram(
594  __FILE__, __LINE__, __func__,
595  "11 first characters of annotation stab must contain "
596  "annotation ID ending with ':' e.g. '0x00011000:'");
597  }
598 
599  Word annId = Conversion::toInt(annString.substr(0,10));
600 
601  std::string payString = annString.substr(11,annString.length() - 10);
602  std::vector<Byte> payload;
603 
604  for (unsigned int j = 0; j < payString.length(); j++) {
605  payload.push_back(payString.at(j));
606  }
607 
608  instr->addAnnotation(new InstructionAnnotation(annId, payload));
609  }
610 }

References __func__, TPEF::SymbolElement::absolute(), TPEF::InstructionElement::addAnnotation(), addedResources_, TPEF::Section::addElement(), annotationes_, assert, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TPEF::MoveElement::destinationIndex(), TPEF::MoveElement::destinationType(), TPEF::MoveElement::destinationUnit(), TPEF::CodeSection::element(), TPEF::Section::element(), TPEF::Section::elementCount(), GCC_MODULE_START_SYMBOL1, GCC_MODULE_START_SYMBOL2, TPEF::CodeSection::instruction(), TPEF::CodeSection::instructionCount(), TPEF::CodeSection::instructionToSectionIndex(), TPEF::InstructionElement::isImmediate(), TPEF::Section::link(), TPEF::MoveElement::MF_UNIT, TPEF::SymbolElement::name(), TPEF::AOutSectionReader::parent(), TPEF::CodeSymElement::reference(), TPEF::ReferenceManager::SafePointer::replaceAllReferences(), TPEF::AOutSymbolSectionReader::CompilationModule::resources_, TPEF::SymbolElement::section(), TPEF::SymbolElement::setAbsolute(), TPEF::SymbolElement::setBinding(), TPEF::MoveElement::setDestinationIndex(), TPEF::Section::setElement(), TPEF::SymbolElement::setName(), TPEF::CodeSymElement::setReference(), TPEF::SymbolElement::setSection(), TPEF::CodeSymElement::setSize(), TPEF::MoveElement::setSourceIndex(), TPEF::CodeSymElement::size(), TPEF::MoveElement::sourceIndex(), TPEF::MoveElement::sourceType(), TPEF::MoveElement::sourceUnit(), TPEF::AOutSymbolSectionReader::CompilationModule::startAddress_, TPEF::SymbolElement::STB_LOCAL, TPEF::SymbolElement::STT_CODE, TPEF::SymbolElement::STT_NOTYPE, Conversion::toInt(), TPEF::SymbolElement::type(), and TPEF::ResourceElement::UNIVERSAL_FU.

Here is the call graph for this function:

◆ initializeSymbol()

SymbolElement * TPEF::AOutSymbolSectionReader::initializeSymbol ( BinaryStream stream,
SectionOffset  sectionOffset,
AOutReader reader 
) const
private

Creates and initilizes one symbol element.

Now only non-stabb symbols are read.

Parameters
streamThe stream to be read from.
sectionOffsetThe offset of the element in section.
readerThe base reader for a.out.
Returns
Newly created symbol.
Exceptions
KeyAlreadyExistsIf key used to register object is in use.
UnreachableStreamIf there occurs problems with stream.
OutOfRangeIf offset read is out of the section.

Definition at line 261 of file AOutSymbolSectionReader.cc.

263  {
264  StringSection* stringSection =
265  dynamic_cast<AOutReader*>(parent())->stringSection();
266 
267  SymbolElement *element = NULL;
268 
269  // first there is an offset to string in string table
270  Word strtabOff = stream.readWord();
271 
272  // type of symbol
273  Byte type = stream.readByte();
274 
275  // not used
276  Byte other = stream.readByte();
277 
278  // description of the symbol, reserved for debugger use
279  // not needed in tpef (there is debug section for that)
280  HalfWord desc = stream.readHalfWord();
281 
282  // offset of the value of the symbol
283  Word value = stream.readWord();
284 
285  // key to string of symbol
286  SectionOffsetKey strOffKey =
287  SectionOffsetKey(AOutReader::ST_STRING, strtabOff);
288 
289 
290  // create element of right type
291  switch (type&(~AOutReader::N_EXT)) {
292 
293  case AOutReader::N_UNDF: {
294  element = new NoTypeSymElement();
295  element->setSection(reader->nullSection());
296  break;
297  }
298 
299  case AOutReader::N_TEXT: {
300  // create code symbols only if there really is code section
301  if (reader->header().sectionSizeText() != 0) {
302 
303  // if new compilation module start symbol, start new module for
304  // resource id resolving...
305  std::string symbolName =
306  stringSection->chunk2String(stringSection->chunk(strtabOff));
307 
308  if (GCC_MODULE_START_SYMBOL1 == symbolName) {
309  Word tpefAddress = value/8;
310  addedResources_.push_back(CompilationModule(tpefAddress));
311  }
312 
313  element = new CodeSymElement();
314 
315  // convert a.out address to suitable for section offset key..
316  value = reader->sectionOffsetOfAddress(value);
317 
318  SectionOffsetKey valueKey(AOutReader::ST_TEXT, value);
319  CodeSymElement *elem = dynamic_cast<CodeSymElement*>(element);
320  elem->setReference(CREATE_SAFEPOINTER(valueKey));
321 
322  SectionKey sKey(AOutReader::ST_TEXT);
323  element->setSection(CREATE_SAFEPOINTER(sKey));
324 
325  } else { // otherwise create no type symbol
326  element = new NoTypeSymElement();
327  element->setSection(reader->nullSection());
328  }
329 
330  break;
331  }
332 
333  case AOutReader::N_DATA:
334  case AOutReader::N_BSS: {
335  element = new DataSymElement();
336 
337  value = reader->sectionOffsetOfAddress(value);
338 
339  SectionOffsetKey valueKey(type&(~AOutReader::N_EXT), value);
340  DataSymElement *elem = dynamic_cast<DataSymElement*>(element);
341  elem->setReference(CREATE_SAFEPOINTER(valueKey));
342 
343 
344  elem->setSize(DATA_SYMBOL_SIZE);
345 
346  SectionKey sKey(type&(~AOutReader::N_EXT));
347  element->setSection(CREATE_SAFEPOINTER(sKey));
348  break;
349  }
350 
351  case AOutReader::N_FN: {
352  element = new FileSymElement();
353  element->setSection(reader->nullSection());
354  break;
355  }
356 
357  case AOutReader::N_PRTAB: {
358  std::string symbolName =
359  stringSection->chunk2String(stringSection->chunk(strtabOff));
360 
361  if (!MapTools::containsKey(resolvedResources_, symbolName)) {
362  resolvedResources_[symbolName] = value;
363  } else {
364  // if symbol with same name has different value
365  // add replacement entry
366  Word resolvedValue = resolvedResources_[symbolName];
367  if (value != resolvedValue) {
368  addedResources_[addedResources_.size()-1].resources_[value] =
369  resolvedValue;
370  }
371  }
372 
373  return NULL;
374  }
375 
376  case AOutReader::N_ANN: {
377 
378  std::string symbolName =
379  stringSection->chunk2String(stringSection->chunk(strtabOff));
380 
381  // value - address of instruction, symbolName - all the data
382  Word numberOfInstruction = value / 8;
383  annotationes_.push_back(std::pair<Word, std::string>(numberOfInstruction, symbolName));
384  return NULL;
385  }
386 
387  // rest of symbols are stored as stabs
388  default: {
389  DebugStabElem* stab =
390  new DebugStabElem(type, other, desc, value);
391 
392  stab->setDebugString(CREATE_SAFEPOINTER(strOffKey));
393 
394  reader->debugSection()->addElement(stab);
395 
396  return NULL;
397  } break;
398 
399  }
400 
401  // inform ReferenceManager about new symbol
402  SectionOffsetKey offKey =
403  SectionOffsetKey(AOutReader::ST_SYMBOL, sectionOffset);
404  SafePointer::addObjectReference(offKey, element);
405 
406  // figure out symbol linkage scope (local/global)
407  if (static_cast<Byte>(type) & static_cast<Byte>(AOutReader::N_EXT)) {
408  element->setBinding(SymbolElement::STB_GLOBAL);
409  } else {
410  element->setBinding(SymbolElement::STB_LOCAL);
411  }
412 
413  // symbol name string
414  element->setName(CREATE_SAFEPOINTER(strOffKey));
415 
416  return element;
417 }

References addedResources_, TPEF::Section::addElement(), TPEF::ReferenceManager::SafePointer::addObjectReference(), annotationes_, TPEF::RawSection::chunk(), TPEF::StringSection::chunk2String(), MapTools::containsKey(), DATA_SYMBOL_SIZE, TPEF::AOutReader::debugSection(), GCC_MODULE_START_SYMBOL1, TPEF::AOutReader::header(), TPEF::AOutReader::N_ANN, TPEF::AOutReader::N_BSS, TPEF::AOutReader::N_DATA, TPEF::AOutReader::N_EXT, TPEF::AOutReader::N_FN, TPEF::AOutReader::N_PRTAB, TPEF::AOutReader::N_TEXT, TPEF::AOutReader::N_UNDF, TPEF::AOutReader::nullSection(), TPEF::AOutSectionReader::parent(), TPEF::BinaryStream::readByte(), TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), resolvedResources_, TPEF::AOutReader::sectionOffsetOfAddress(), TPEF::AOutReader::Header::sectionSizeText(), TPEF::SymbolElement::setBinding(), TPEF::DebugElement::setDebugString(), TPEF::SymbolElement::setName(), TPEF::DataSymElement::setReference(), TPEF::CodeSymElement::setReference(), TPEF::SymbolElement::setSection(), TPEF::DataSymElement::setSize(), TPEF::AOutReader::ST_STRING, TPEF::AOutReader::ST_SYMBOL, TPEF::AOutReader::ST_TEXT, TPEF::SymbolElement::STB_GLOBAL, TPEF::SymbolElement::STB_LOCAL, and type().

Referenced by readData().

Here is the call graph for this function:

◆ operator=()

AOutSymbolSectionReader& TPEF::AOutSymbolSectionReader::operator= ( const AOutSymbolSectionReader )
private

Assignment not allowed.

◆ readData()

void TPEF::AOutSymbolSectionReader::readData ( BinaryStream stream,
Section section 
) const
protectedvirtual

Reads a.out symbol section out of stream and stores it in section.

Parameters
streamThe stream to be read from.
sectionThe section in which data is stored.
Exceptions
UnreachableStreamIf reading of section fails.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome of read values were out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Implements TPEF::SectionReader.

Definition at line 112 of file AOutSymbolSectionReader.cc.

113  {
114  StringSection* stringSection =
115  dynamic_cast<AOutReader*>(parent())->stringSection();
116 
117  FileOffset offset = stream.readPosition();
118  AOutReader* reader = dynamic_cast<AOutReader*>(parent());
119  assert(reader != NULL);
120 
121  // create undef symbol to start of section (needed by TPEF)
122  SymbolElement *undefSymbol = new NoTypeSymElement();
123 
124  SectionOffsetKey nullStringKey =
125  SectionOffsetKey(AOutReader::ST_STRING, 0);
126 
127  undefSymbol->setName(CREATE_SAFEPOINTER(nullStringKey));
128  undefSymbol->setSection(reader->nullSection());
129 
130  SectionIndexKey undefSymbolKey =
131  SectionIndexKey(AOutReader::ST_SYMBOL, 0);
132  SafePointer::addObjectReference(undefSymbolKey, undefSymbol);
133 
134  section->addElement(undefSymbol);
135 
136  // in this point there is no recources added yet
137  resolvedResources_.clear();
138  addedResources_.clear();
139 
140  // symbols start in a.out with index 0
141  int symIndex = 0;
142  while (stream.readPosition() <
143  offset + reader->header().sectionSizeSymbol()) {
144 
145  SectionOffset sectionOffset = stream.readPosition() - offset;
146 
147  SymbolElement* elem =
148  initializeSymbol(stream, sectionOffset, reader);
149 
150  if (elem != NULL) {
151  SectionIndexKey symIndexKey =
152  SectionIndexKey(AOutReader::ST_SYMBOL, symIndex + 1);
153  SafePointer::addObjectReference(symIndexKey, elem);
154 
155  section->addElement(elem);
156 
157  }
158 
159  // always remember to increment index counter, even if symbol is not
160  // created
161  symIndex++;
162  }
163 
164 
165  // ----------------------------------------------------------------------
166  // write resource table out of N_PRTAB stabs collected from symbol table
167  // ----------------------------------------------------------------------
168 
169  ResourceSection* resourceTable =
170  dynamic_cast<AOutReader*>(parent())->resourceTable();
171 
172  ResourceElement *resource = NULL;
173 
174  while (!resolvedResources_.empty()) {
175  Word value = (*(resolvedResources_.begin())).second;
176  Chunk* name =
177  stringSection->string2Chunk(
178  (*(resolvedResources_.begin())).first);
179 
180  // if operation register, make entry to resource table
181  if (value > AOutReader::FIRST_FU_REGISTER) {
182 
183  resource = new ResourceElement();
184  resource->setId(value);
185  resource->setType(ResourceElement::MRT_OP);
186 
187  resource->setName(
188  CREATE_SAFEPOINTER(
189  SectionOffsetKey(AOutReader::ST_STRING, name->offset())));
190 
191  resourceTable->addElement(resource);
192 
193  // the very first of FU registers in a.out is
194  // "return-address" special register
195  } else if (value == AOutReader::FIRST_FU_REGISTER) {
196 
197  resource = new ResourceElement();
198  resource->setId(value);
199  resource->setType(ResourceElement::MRT_SR);
200 
201  resource->setName(
202  CREATE_SAFEPOINTER(
203  SectionOffsetKey(AOutReader::ST_STRING, name->offset())));
204 
205  resourceTable->addElement(resource);
206  }
207 
208  resolvedResources_.erase(resolvedResources_.begin());
209  }
210 
211  // add int register file
212  resource = new ResourceElement();
213  resource->setId(ResourceElement::INT_RF);
214  resource->setType(ResourceElement::MRT_RF);
215  resource->setName(CREATE_SAFEPOINTER(nullStringKey));
216  resourceTable->addElement(resource);
217 
218  // add fp registerfile
219  resource = new ResourceElement();
220  resource->setId(ResourceElement::FP_RF);
221  resource->setType(ResourceElement::MRT_RF);
222  resource->setName(CREATE_SAFEPOINTER(nullStringKey));
223  resourceTable->addElement(resource);
224 
225  // add bool register file
226  resource = new ResourceElement();
227  resource->setType(ResourceElement::MRT_RF);
228  resource->setId(ResourceElement::BOOL_RF);
229  resource->setName(CREATE_SAFEPOINTER(nullStringKey));
230  resourceTable->addElement(resource);
231 
232  // add unit
233  resource = new ResourceElement();
234  resource->setType(ResourceElement::MRT_UNIT);
235  resource->setId(ResourceElement::UNIVERSAL_FU);
236  resource->setName(CREATE_SAFEPOINTER(nullStringKey));
237  resourceTable->addElement(resource);
238 
239  // add bus
240  resource = new ResourceElement();
241  resource->setType(ResourceElement::MRT_BUS);
242  resource->setId(ResourceElement::UNIVERSAL_BUS);
243  resource->setName(CREATE_SAFEPOINTER(nullStringKey));
244  resourceTable->addElement(resource);
245 }

References addedResources_, TPEF::Section::addElement(), TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::ResourceElement::BOOL_RF, TPEF::AOutReader::FIRST_FU_REGISTER, TPEF::ResourceElement::FP_RF, TPEF::AOutReader::header(), initializeSymbol(), TPEF::ResourceElement::INT_RF, TPEF::ResourceElement::MRT_BUS, TPEF::ResourceElement::MRT_OP, TPEF::ResourceElement::MRT_RF, TPEF::ResourceElement::MRT_SR, TPEF::ResourceElement::MRT_UNIT, TPEF::AOutReader::nullSection(), TPEF::Chunk::offset(), TPEF::AOutSectionReader::parent(), TPEF::BinaryStream::readPosition(), resolvedResources_, TPEF::AOutReader::Header::sectionSizeSymbol(), TPEF::ResourceElement::setId(), TPEF::SymbolElement::setName(), TPEF::ResourceElement::setName(), TPEF::SymbolElement::setSection(), TPEF::ResourceElement::setType(), TPEF::AOutReader::ST_STRING, TPEF::AOutReader::ST_SYMBOL, TPEF::StringSection::string2Chunk(), TPEF::ResourceElement::UNIVERSAL_BUS, and TPEF::ResourceElement::UNIVERSAL_FU.

Here is the call graph for this function:

◆ type()

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

Returns the type of section that this reader reads.

Returns
The type of section this reader can read.

Implements TPEF::SectionReader.

Definition at line 95 of file AOutSymbolSectionReader.cc.

95  {
96  return Section::ST_SYMTAB;
97 }

References TPEF::Section::ST_SYMTAB.

Referenced by initializeSymbol().

Member Data Documentation

◆ addedResources_

std::vector<CompilationModule> TPEF::AOutSymbolSectionReader::addedResources_
mutableprivate

List of compilation modules of a.out.

Definition at line 143 of file AOutSymbolSectionReader.hh.

Referenced by finalize(), initializeSymbol(), and readData().

◆ annotationes_

std::vector< std::pair<Word, std::string> > TPEF::AOutSymbolSectionReader::annotationes_
mutableprivate

Definition at line 145 of file AOutSymbolSectionReader.hh.

Referenced by finalize(), and initializeSymbol().

◆ DATA_SYMBOL_SIZE

const Word TPEF::AOutSymbolSectionReader::DATA_SYMBOL_SIZE = 4
staticprivate

Data symbol size in bytes.

Definition at line 103 of file AOutSymbolSectionReader.hh.

Referenced by initializeSymbol().

◆ GCC_MODULE_START_SYMBOL1

const std::string TPEF::AOutSymbolSectionReader::GCC_MODULE_START_SYMBOL1 = "gcc2_compiled."
staticprivate

One of the symbols that are used to indicate start of new compilation module in a.out symbol table.

Definition at line 107 of file AOutSymbolSectionReader.hh.

Referenced by finalize(), and initializeSymbol().

◆ GCC_MODULE_START_SYMBOL2

const std::string TPEF::AOutSymbolSectionReader::GCC_MODULE_START_SYMBOL2 = "___gnu_compiled_c"
staticprivate

One of the symbols that are used to indicate start of new compilation module in a.out symbol table.

Definition at line 111 of file AOutSymbolSectionReader.hh.

Referenced by finalize().

◆ proto_

AOutSymbolSectionReader TPEF::AOutSymbolSectionReader::proto_
staticprivate

Class-wide (unique) prototype instance of AOutSymbolSectionReader registered into SectionReader.

Definition at line 115 of file AOutSymbolSectionReader.hh.

◆ resolvedResources_

std::map<std::string, Word> TPEF::AOutSymbolSectionReader::resolvedResources_
mutableprivate

Resource id:s for strings.

Definition at line 140 of file AOutSymbolSectionReader.hh.

Referenced by initializeSymbol(), and readData().


The documentation for this class was generated from the following files:
TPEF::ResourceElement::MRT_OP
@ MRT_OP
Operation operand or function unit register.
Definition: ResourceElement.hh:56
TPEF::ResourceElement::MRT_BUS
@ MRT_BUS
Transport bus.
Definition: ResourceElement.hh:53
TPEF::AOutSymbolSectionReader::DATA_SYMBOL_SIZE
static const Word DATA_SYMBOL_SIZE
Data symbol size in bytes.
Definition: AOutSymbolSectionReader.hh:103
TPEF::AOutSymbolSectionReader::initializeSymbol
SymbolElement * initializeSymbol(BinaryStream &stream, SectionOffset sectionOffset, AOutReader *reader) const
Definition: AOutSymbolSectionReader.cc:261
TPEF::Section::ST_SYMTAB
@ ST_SYMTAB
Symbol table.
Definition: Section.hh:72
TPEF::AOutReader::N_EXT
@ N_EXT
Mask bit for external.
Definition: AOutReader.hh:69
TPEF::AOutReader::N_PRTAB
@ N_PRTAB
TCE processors resource entry.
Definition: AOutReader.hh:102
TPEF::ResourceElement::BOOL_RF
@ BOOL_RF
Universal boolean register file.
Definition: ResourceElement.hh:68
TPEF::MoveElement::MF_UNIT
@ MF_UNIT
Function unit.
Definition: MoveElement.hh:56
TPEF::ResourceElement::MRT_SR
@ MRT_SR
Special register.
Definition: ResourceElement.hh:58
TPEF::AOutSymbolSectionReader::GCC_MODULE_START_SYMBOL2
static const std::string GCC_MODULE_START_SYMBOL2
One of the symbols that are used to indicate start of new compilation module in a....
Definition: AOutSymbolSectionReader.hh:111
TPEF::AOutSymbolSectionReader::resolvedResources_
std::map< std::string, Word > resolvedResources_
Resource id:s for strings.
Definition: AOutSymbolSectionReader.hh:140
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::ReferenceManager::SafePointer::addObjectReference
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
Definition: SafePointer.cc:306
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::AOutReader::N_ANN
@ N_ANN
TCE annotation entry.
Definition: AOutReader.hh:103
TPEF::AOutReader::N_TEXT
@ N_TEXT
Text.
Definition: AOutReader.hh:64
TPEF::AOutReader::N_DATA
@ N_DATA
Data.
Definition: AOutReader.hh:65
TPEF::AOutSectionReader::parent
virtual BinaryReader * parent() const
Definition: AOutSectionReader.cc:57
TPEF::SymbolElement::STB_GLOBAL
@ STB_GLOBAL
Visible to all files that are combined in TPEF file.
Definition: SymbolElement.hh:58
TPEF::AOutSymbolSectionReader::annotationes_
std::vector< std::pair< Word, std::string > > annotationes_
Definition: AOutSymbolSectionReader.hh:145
IllegalProgram
Definition: Exception.hh:895
__func__
#define __func__
Definition: Application.hh:67
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::AOutSymbolSectionReader::addedResources_
std::vector< CompilationModule > addedResources_
List of compilation modules of a.out.
Definition: AOutSymbolSectionReader.hh:143
TPEF::SectionReader::registerSectionReader
static void registerSectionReader(const SectionReader *sReader)
Definition: SectionReader.cc:145
TPEF::AOutSectionReader::AOutSectionReader
AOutSectionReader()
Definition: AOutSectionReader.cc:41
TPEF::AOutReader::ST_TEXT
@ ST_TEXT
Text section.
Definition: AOutReader.hh:116
TPEF::ResourceElement::MRT_RF
@ MRT_RF
Register file.
Definition: ResourceElement.hh:55
TPEF::SymbolElement::STT_CODE
@ STT_CODE
Associated with executable code.
Definition: SymbolElement.hh:69
TPEF::AOutReader::N_FN
@ N_FN
File name.
Definition: AOutReader.hh:68
TPEF::AOutReader::N_BSS
@ N_BSS
BSS.
Definition: AOutReader.hh:66
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
TPEF::AOutSymbolSectionReader::GCC_MODULE_START_SYMBOL1
static const std::string GCC_MODULE_START_SYMBOL1
One of the symbols that are used to indicate start of new compilation module in a....
Definition: AOutSymbolSectionReader.hh:107
TPEF::AOutReader::FIRST_FU_REGISTER
static const Word FIRST_FU_REGISTER
Index of the first function unit register.
Definition: AOutReader.hh:137
TPEF::AOutReader::ST_SYMBOL
@ ST_SYMBOL
Symbol table.
Definition: AOutReader.hh:119
TPEF::ResourceElement::MRT_UNIT
@ MRT_UNIT
Function unit.
Definition: ResourceElement.hh:54
TPEF::SymbolElement::STT_NOTYPE
@ STT_NOTYPE
Type is not defined.
Definition: SymbolElement.hh:67
Conversion::toInt
static int toInt(const T &source)
TPEF::ResourceElement::UNIVERSAL_BUS
@ UNIVERSAL_BUS
Universal bus.
Definition: ResourceElement.hh:64
TPEF::ResourceElement::FP_RF
@ FP_RF
Universal floating point register file.
Definition: ResourceElement.hh:69
TPEF::ResourceElement::INT_RF
@ INT_RF
Universal integer register file.
Definition: ResourceElement.hh:67
TPEF::ReferenceManager::SafePointer::replaceAllReferences
static void replaceAllReferences(SafePointable *newObj, SafePointable *oldObj)
TPEF::AOutReader::N_UNDF
@ N_UNDF
Undefined.
Definition: AOutReader.hh:62
TPEF::SymbolElement::STB_LOCAL
@ STB_LOCAL
Not visible outside the object file that contains it's definition.
Definition: SymbolElement.hh:56
TPEF::AOutSymbolSectionReader::type
virtual Section::SectionType type() const
Definition: AOutSymbolSectionReader.cc:95
TPEF::ResourceElement::UNIVERSAL_FU
@ UNIVERSAL_FU
Universal function unit.
Definition: ResourceElement.hh:65
TPEF::AOutReader::ST_STRING
@ ST_STRING
String table.
Definition: AOutReader.hh:120