OpenASIP 2.2
Loading...
Searching...
No Matches
AOutSymbolSectionReader.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file AOutSymbolSectionReader.hh
26 *
27 * Declaration of AOutSymbolSectionReader.
28 *
29 * @author Jussi Nykänen 2003 (nykanen-no.spam-cs.tut.fi)
30 * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
31 * @note reviewed 23 October 2003 by pj, am, ll, jn
32 *
33 * @note rating: yellow
34 */
35
36#ifndef TTA_AOUT_SYMBOL_SECTION_READER_HH
37#define TTA_AOUT_SYMBOL_SECTION_READER_HH
38
39#include <deque>
40
41#include "AOutSectionReader.hh"
42#include "Section.hh"
43#include "Exception.hh"
44#include "TPEFBaseType.hh"
45
46namespace TPEF {
47
48 class SymbolElement;
49 class AOutReader;
50
51/**
52 * Reads symbol table section from a.out binary file.
53 */
55
56public:
58
59protected:
60
62
63 virtual Section::SectionType type() const;
64
65 virtual void finalize(Section* section) const;
66
67 virtual void readData(BinaryStream& stream, Section* section) const;
68
69private:
70 /**
71 * All the information of read a.out stab.
72 */
73 struct StabData {
75 Byte aType, Byte anOther, HalfWord aDescr,
76 Word aValue, Word aName) :
77 stabType(aType), other(anOther), description(aDescr),
78 value(aValue), nameOffset(aName) {
79 }
80
81 /// Stab type.
83 /// Stab other field.
85 /// Description field.
86 HalfWord description;
87 /// Value of the stab.
88 Word value;
89 /// Offset to string table.
91 };
92
94 BinaryStream& stream, SectionOffset sectionOffset,
95 AOutReader* reader) const;
96
97 /// Copying not allowed.
99 /// Assignment not allowed.
101
102 /// Data symbol size in bytes.
103 static const Word DATA_SYMBOL_SIZE;
104
105 /// One of the symbols that are used to indicate start of new
106 /// compilation module in a.out symbol table
107 static const std::string GCC_MODULE_START_SYMBOL1;
108
109 /// One of the symbols that are used to indicate start of new
110 /// compilation module in a.out symbol table
111 static const std::string GCC_MODULE_START_SYMBOL2;
112
113 /// Class-wide (unique) prototype instance of AOutSymbolSectionReader
114 /// registered into SectionReader.
116
117 /**
118 * Map of recources for each compilation module.
119 *
120 * In linked a.out the same resource symbols are added for
121 * every different compilation unit, with a different value.
122 *
123 * This class stores information how resource ids should be replaced
124 * for instructions starting from startAddress. There is own
125 * replacement map for each compilation unit.
126 */
128 CompilationModule(Word startAddress) :
129 startAddress_(startAddress) {
130 }
131
132 /// Start address of linked compilation module in a.out
134
135 /// Resources id replacements for the compilation module.
136 std::map<Word, SectionOffset> resources_;
137 };
138
139 /// Resource id:s for strings.
140 mutable std::map<std::string, Word> resolvedResources_;
141
142 /// List of compilation modules of a.out
143 mutable std::vector<CompilationModule> addedResources_;
144
145 mutable std::vector< std::pair<Word, std::string> > annotationes_;
146};
147}
148
149#endif
unsigned char Byte
Definition BaseType.hh:116
static const std::string GCC_MODULE_START_SYMBOL1
One of the symbols that are used to indicate start of new compilation module in a....
SymbolElement * initializeSymbol(BinaryStream &stream, SectionOffset sectionOffset, AOutReader *reader) const
AOutSymbolSectionReader & operator=(const AOutSymbolSectionReader &)
Assignment not allowed.
static AOutSymbolSectionReader proto_
Class-wide (unique) prototype instance of AOutSymbolSectionReader registered into SectionReader.
virtual void finalize(Section *section) const
static const Word DATA_SYMBOL_SIZE
Data symbol size in bytes.
std::vector< CompilationModule > addedResources_
List of compilation modules of a.out.
std::vector< std::pair< Word, std::string > > annotationes_
virtual Section::SectionType type() const
std::map< std::string, Word > resolvedResources_
Resource id:s for strings.
static const std::string GCC_MODULE_START_SYMBOL2
One of the symbols that are used to indicate start of new compilation module in a....
virtual void readData(BinaryStream &stream, Section *section) const
AOutSymbolSectionReader(const AOutSymbolSectionReader &)
Copying not allowed.
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Word startAddress_
Start address of linked compilation module in a.out.
std::map< Word, SectionOffset > resources_
Resources id replacements for the compilation module.
StabData(Byte aType, Byte anOther, HalfWord aDescr, Word aValue, Word aName)