OpenASIP
2.0
|
#include <AOutReader.hh>
Classes | |
class | Header |
Public Types | |
enum | SymbolType { N_UNDF = 0x0, N_ABS = 0x2, N_TEXT = 0x4, N_DATA = 0x6, N_BSS = 0x8, N_COMM = 0x12, N_FN = 0x1e, N_EXT = 0x1, N_TYPE = 0x1e, N_TJ = 0x76, N_JTE = 0x96, N_MEM = 0xb6, N_FC = 0xd6, N_STAB = 0xe0, N_GSYM = 0x20, N_FNAME = 0x22, N_FUN = 0x24, N_STSYM = 0x26, N_LCSYM = 0x28, N_MAIN = 0x2a, N_RSYM = 0x40, N_SLINE = 0x44, N_SSYM = 0x60, N_SO = 0x64, N_LSYM = 0x80, N_BINCL = 0x82, N_SOL = 0x84, N_PSYM = 0xa0, N_EINCL = 0xa2, N_LBRAC = 0xc0, N_EXCL = 0xc2, N_RBRAC = 0xe0, N_BCOMM = 0xe2, N_ECOMM = 0xe4, N_ECOML = 0xe8, N_LENG = 0xfe, N_PC = 0x30, N_M2C = 0x42, N_SCOPE = 0xc4, N_BROWS = 0x48, N_PRTAB = 0xd2, N_ANN = 0xa4 } |
enum | AOutSectionID { ST_UNDEF = 0x00, ST_TEXT = N_TEXT, ST_DATA = N_DATA, ST_UDATA = N_BSS, ST_SYMBOL = 0x10, ST_STRING = 0x12 } |
Public Types inherited from TPEF::BinaryReader | |
typedef unsigned long | Length |
Public Member Functions | |
SectionOffset | sectionOffsetOfAddress (AddressImage address) const |
AddressImage | addressOfElement (SectionElement *elem) const |
ASpaceElement * | aSpaceOfElement (SectionElement *elem) const |
ResourceSection * | resourceTable () const |
NullSection * | nullSection () const |
DebugSection * | debugSection () const |
StringSection * | stringSection () const |
CodeSection * | textSection () const |
Public Member Functions inherited from TPEF::BinaryReader | |
virtual | ~BinaryReader () |
Static Public Member Functions | |
static BinaryReader * | instance () |
static const Header & | header () |
Static Public Member Functions inherited from TPEF::BinaryReader | |
static Binary * | readBinary (BinaryStream &stream) |
Static Public Attributes | |
static const Word | INT_REGISTERS = 1024 |
Number of integer registers. More... | |
static const Word | FP_REGISTERS = 1024 |
Number of floating-point registers. More... | |
static const Word | BOOL_REGISTERS = 1 |
Number of Boolean registers. More... | |
static const Word | FIRST_INT_REGISTER = 0 |
Index of the first integer register in a.out. More... | |
static const Word | FIRST_FP_REGISTER = FIRST_INT_REGISTER + INT_REGISTERS |
Index of the first floating-point register. More... | |
static const Word | FIRST_BOOL_REGISTER = FIRST_FP_REGISTER + FP_REGISTERS |
Index of the first Boolean register. More... | |
static const Word | FIRST_FU_REGISTER = FIRST_BOOL_REGISTER + BOOL_REGISTERS |
Index of the first function unit register. More... | |
static const Byte | AOUT_INSTRUCTION_SIZE = 8 |
Size of one instruction in a.out file. More... | |
static const Byte | AOUT_BITS_PER_MAU = 8 |
Minimum addressable word of address space. More... | |
static const Byte | AOUT_WORD_ALIGN = 4 |
Aligment of address space. More... | |
static const Byte | AOUT_WORD_SIZE = 4 |
Word size of address space. More... | |
static const char * | AOUT_CODE_ASPACE_NAME = "universal_instructions" |
Name of universal machines code address space. More... | |
static const char * | AOUT_DATA_ASPACE_NAME = "universal_data" |
Name of universal machines data address space. More... | |
Protected Member Functions | |
AOutReader () | |
virtual | ~AOutReader () |
virtual Binary * | readData (BinaryStream &stream) const |
virtual bool | isMyStreamType (BinaryStream &stream) const |
Protected Member Functions inherited from TPEF::BinaryReader | |
BinaryReader () | |
Private Member Functions | |
void | readHeader (BinaryStream &stream) const |
void | readSection (BinaryStream &stream, FileOffset startPosition, Section *section, Length length) const |
void | addOrDeleteSection (Section *section, Binary *binary) const |
AOutReader (const AOutReader &) | |
Copying not allowed. More... | |
AOutReader & | operator= (const AOutReader &) |
Assignment not allowed. More... | |
Private Attributes | |
ASpaceElement * | undefASpace_ |
Undefined address space. More... | |
ASpaceElement * | codeASpace_ |
Address space of text section. More... | |
ASpaceElement * | dataASpace_ |
Address space of data sections. More... | |
Static Private Attributes | |
static ResourceSection * | resourceTable_ = NULL |
static NullSection * | nullSection_ = NULL |
static DebugSection * | debugSection_ = NULL |
static StringSection * | stringSection_ = NULL |
static CodeSection * | textSection_ = NULL |
static const HalfWord | OMAGIC = 0x0107 |
Move a.out format identifier. More... | |
static const Byte | FILE_HEADER_SIZE = 8 * sizeof(Word) |
Size of file header. More... | |
static Header | header_ |
Header of a.out file. More... | |
static AOutReader * | proto_ = NULL |
Prototype instance of AOutReader registered into BinaryReader. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from TPEF::BinaryReader | |
static void | registerBinaryReader (BinaryReader *reader) |
Reads binary file that is in TTA a.out format.
Definition at line 54 of file AOutReader.hh.
Names for a.out sections.
Sections are expected in this order in a.out file. Since there is only one section of each type, these names can be used as section identifiers.
Enumerator | |
---|---|
ST_UNDEF | Undefined section. |
ST_TEXT | Text section. |
ST_DATA | Data section. |
ST_UDATA | Uninitialized data section. |
ST_SYMBOL | Symbol table. |
ST_STRING | String table. |
Definition at line 114 of file AOutReader.hh.
TODO: get these from tce-frontend a.out symbols. (from MOVE/sched/exec.h)
Enumerator | |
---|---|
N_UNDF | Undefined. |
N_ABS | Absolute. |
N_TEXT | Text. |
N_DATA | Data. |
N_BSS | BSS. |
N_COMM | Common (internal to ld). |
N_FN | File name. |
N_EXT | Mask bit for external. |
N_TYPE | Mask bits for resolving symbol type. |
N_TJ | Table jump. |
N_JTE | Jump table entry. |
N_MEM | Memory reference. |
N_FC | Function call. |
N_STAB | Mask for stabs. |
N_GSYM | Global. |
N_FNAME | Procedure name (f77). |
N_FUN | Procedure. |
N_STSYM | Static. |
N_LCSYM | .lcomm. |
N_MAIN | Name of main rutine. |
N_RSYM | Register. |
N_SLINE | Source line. |
N_SSYM | Structure. |
N_SO | Source file name. |
N_LSYM | Local. |
N_BINCL | Header file. |
N_SOL | #included file name. |
N_PSYM | Parameter. |
N_EINCL | End of include file. |
N_LBRAC | Left bracket. |
N_EXCL | Excluded include file. |
N_RBRAC | Right bracket. |
N_BCOMM | Begin common. |
N_ECOMM | End common. |
N_ECOML | End common (local name). |
N_LENG | Second symbol table entry with length. |
N_PC | Global pascal symbol. |
N_M2C | Compilation unit symbol table entry. |
N_SCOPE | Scope information. |
N_BROWS | Sun source code browser. |
N_PRTAB | TCE processors resource entry. |
N_ANN | TCE annotation entry. |
Definition at line 61 of file AOutReader.hh.
|
protected |
Constructor.
Creates Header and registers itself to BinaryReader.
Definition at line 101 of file AOutReader.cc.
References TPEF::BinaryReader::registerBinaryReader().
|
protectedvirtual |
|
private |
Copying not allowed.
Referenced by readData().
AddressImage TPEF::AOutReader::addressOfElement | ( | SectionElement * | elem | ) | const |
Referenced by TPEF::AOutRelocationSectionReader::finalize().
ASpaceElement* TPEF::AOutReader::aSpaceOfElement | ( | SectionElement * | elem | ) | const |
Referenced by TPEF::AOutRelocationSectionReader::finalize().
DebugSection* TPEF::AOutReader::debugSection | ( | ) | const |
Referenced by TPEF::AOutSymbolSectionReader::initializeSymbol().
|
static |
|
static |
Referenced by TPEF::AOutSectionReader::parent().
|
protectedvirtual |
Checks whether AOutReader can read from the given stream.
The test simply consists of checking that file size is at least the size of a.out header. Then it checks whether the third and fourth Byte of stream match the magic number of a.out files. Only 'old impure format' files (not read-only text and not page-aligned for on demand load) are accepted.
This method does not modify the stream position.
stream | The stream to test. |
UnreachableStream | If there occurs an exception with stream. |
Implements TPEF::BinaryReader.
Definition at line 341 of file AOutReader.cc.
References FILE_HEADER_SIZE, OMAGIC, TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readPosition(), TPEF::BinaryStream::setReadPosition(), and TPEF::BinaryStream::sizeOfFile().
NullSection* TPEF::AOutReader::nullSection | ( | ) | const |
|
private |
Assignment not allowed.
|
protectedvirtual |
Does the actual work of reading binary file from stream.
Reads a.out binary file and creates valid TPEF object hierarchy out of it.
stream | Stream to be read from. |
UnreachableStream | If reading of section fails. |
KeyAlreadyExists | Key was in use when trying to register object. |
EndOfFile | If end of file were reached while it shouldn't. |
OutOfRange | Some of read values were out of range. |
WrongSubclass | Some class couldn't do what it was asked for. |
UnexpectedValue | If there was unexpected value when reading. |
Implements TPEF::BinaryReader.
Definition at line 134 of file AOutReader.cc.
References TPEF::Section::addElement(), TPEF::ReferenceManager::SafePointer::addObjectReference(), addOrDeleteSection(), TPEF::Binary::addSection(), AOUT_BITS_PER_MAU, AOUT_CODE_ASPACE_NAME, AOUT_DATA_ASPACE_NAME, AOUT_WORD_ALIGN, AOUT_WORD_SIZE, assert, codeASpace_, TPEF::Section::createSection(), dataASpace_, debugSection_, TPEF::Binary::FA_TTA_TUT, TPEF::Binary::FT_OBJSEQ, header_, TPEF::DataSection::length(), nullSection_, readHeader(), TPEF::BinaryStream::readPosition(), readSection(), resourceTable_, TPEF::AOutReader::Header::sectionSizeData(), TPEF::AOutReader::Header::sectionSizeDataReloc(), TPEF::AOutReader::Header::sectionSizeString(), TPEF::AOutReader::Header::sectionSizeSymbol(), TPEF::AOutReader::Header::sectionSizeText(), TPEF::AOutReader::Header::sectionSizeTextReloc(), TPEF::AOutReader::Header::sectionSizeUData(), TPEF::ASpaceElement::setAlign(), TPEF::Binary::setArch(), TPEF::Section::setASpace(), TPEF::RawSection::setDataLength(), TPEF::Section::setLink(), TPEF::ASpaceElement::setMAU(), TPEF::ASpaceElement::setName(), TPEF::Section::setName(), TPEF::RelocSection::setReferencedSection(), TPEF::Section::setStartingAddress(), TPEF::Binary::setStrings(), TPEF::Binary::setType(), TPEF::ASpaceSection::setUndefinedASpace(), TPEF::ASpaceElement::setWordSize(), TPEF::Section::ST_ADDRSP, TPEF::Section::ST_CODE, TPEF::Section::ST_DATA, ST_DATA, TPEF::Section::ST_DEBUG, TPEF::Section::ST_MR, TPEF::Section::ST_NULL, TPEF::Section::ST_RELOC, ST_STRING, TPEF::Section::ST_STRTAB, ST_SYMBOL, TPEF::Section::ST_SYMTAB, ST_TEXT, TPEF::Section::ST_UDATA, ST_UDATA, TPEF::StringSection::string2Chunk(), stringSection_, textSection_, and undefASpace_.
|
private |
Reads file header from the stream and stores it to a specific object.
stream | Stream to be read from. |
UnreachableStream | If there occurs a problem with stream. |
EndOfFile | If end of file were reached where it shouldn't. |
Definition at line 374 of file AOutReader.cc.
References assert, header_, OMAGIC, TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readPosition(), TPEF::BinaryStream::readWord(), TPEF::AOutReader::Header::sectionSizeData(), TPEF::AOutReader::Header::sectionSizeDataReloc(), TPEF::AOutReader::Header::sectionSizeSymbol(), TPEF::AOutReader::Header::sectionSizeText(), TPEF::AOutReader::Header::sectionSizeTextReloc(), TPEF::AOutReader::Header::setSectionSizeData(), TPEF::AOutReader::Header::setSectionSizeDataReloc(), TPEF::AOutReader::Header::setSectionSizeString(), TPEF::AOutReader::Header::setSectionSizeSymbol(), TPEF::AOutReader::Header::setSectionSizeText(), TPEF::AOutReader::Header::setSectionSizeTextReloc(), TPEF::AOutReader::Header::setSectionSizeUData(), and TPEF::BinaryStream::sizeOfFile().
Referenced by readData().
|
private |
Referenced by readData().
ResourceSection* TPEF::AOutReader::resourceTable | ( | ) | const |
SectionOffset TPEF::AOutReader::sectionOffsetOfAddress | ( | AddressImage | address | ) | const |
StringSection* TPEF::AOutReader::stringSection | ( | ) | const |
CodeSection* TPEF::AOutReader::textSection | ( | ) | const |
|
static |
Minimum addressable word of address space.
Definition at line 143 of file AOutReader.hh.
Referenced by readData().
|
static |
Name of universal machines code address space.
Definition at line 150 of file AOutReader.hh.
Referenced by readData().
|
static |
Name of universal machines data address space.
Definition at line 152 of file AOutReader.hh.
Referenced by readData().
|
static |
Size of one instruction in a.out file.
Definition at line 140 of file AOutReader.hh.
|
static |
|
static |
|
static |
Number of Boolean registers.
Definition at line 128 of file AOutReader.hh.
|
mutableprivate |
Address space of text section.
Definition at line 237 of file AOutReader.hh.
Referenced by readData().
|
mutableprivate |
Address space of data sections.
Definition at line 239 of file AOutReader.hh.
Referenced by readData().
|
staticprivate |
Definition at line 248 of file AOutReader.hh.
Referenced by readData().
|
staticprivate |
|
static |
Index of the first Boolean register.
Definition at line 135 of file AOutReader.hh.
Referenced by TPEF::AOutTextSectionReader::convertAOutIndexToTPEF(), TPEF::AOutTextSectionReader::updateMoveDestination(), and TPEF::AOutTextSectionReader::updateMoveSource().
|
static |
Index of the first floating-point register.
Definition at line 133 of file AOutReader.hh.
Referenced by TPEF::AOutTextSectionReader::convertAOutIndexToTPEF(), TPEF::AOutTextSectionReader::updateMoveDestination(), and TPEF::AOutTextSectionReader::updateMoveSource().
|
static |
Index of the first function unit register.
Definition at line 137 of file AOutReader.hh.
Referenced by TPEF::AOutTextSectionReader::convertAOutIndexToTPEF(), TPEF::AOutSymbolSectionReader::readData(), TPEF::AOutTextSectionReader::updateMoveDestination(), and TPEF::AOutTextSectionReader::updateMoveSource().
|
static |
Index of the first integer register in a.out.
Definition at line 131 of file AOutReader.hh.
Referenced by TPEF::AOutTextSectionReader::convertAOutIndexToTPEF().
|
static |
Number of floating-point registers.
Definition at line 126 of file AOutReader.hh.
|
staticprivate |
Header of a.out file.
Definition at line 262 of file AOutReader.hh.
Referenced by readData(), and readHeader().
|
static |
Number of integer registers.
Definition at line 124 of file AOutReader.hh.
|
staticprivate |
Definition at line 245 of file AOutReader.hh.
Referenced by readData().
|
staticprivate |
Move a.out format identifier.
Definition at line 257 of file AOutReader.hh.
Referenced by isMyStreamType(), and readHeader().
|
staticprivate |
Prototype instance of AOutReader registered into BinaryReader.
AOutReader class.
Definition at line 264 of file AOutReader.hh.
Referenced by ~AOutReader().
|
staticprivate |
Definition at line 242 of file AOutReader.hh.
Referenced by readData().
|
staticprivate |
Definition at line 251 of file AOutReader.hh.
Referenced by readData().
|
staticprivate |
Definition at line 254 of file AOutReader.hh.
Referenced by readData().
|
mutableprivate |