Go to the documentation of this file.
87 bin_(bin), resources_(resources) {
115 "Can't find value for label: " + name);
133 "Can't find address address space for label: " + labelName);
136 return *
labels_[labelName]->aSpace;
164 "Multiply defined lablel: " + name);
169 newElem->
name = name;
170 newElem->
aSpace = &aSpace;
187 "Can't find label: " + name);
205 "Multiply defined procedure: " + name);
279 for (std::set<InternalRelocation*>::iterator iter =
310 Section::createSection(Section::ST_SYMTAB));
322 for (SymbolMap::iterator iter =
labels_.begin();
323 iter !=
labels_.end(); iter++) {
328 assert(ownerSection != NULL);
340 symbol->
setBinding(SymbolElement::STB_GLOBAL);
353 "Can't set label to be global. " +
354 *(
globals_.begin()) +
" is undefined.");
370 "Invalid procedure declaration: " +
375 for (std::set<InternalRelocation*>::iterator iter =
relocs_.begin();
376 iter !=
relocs_.end(); iter++) {
383 assert(relocSect != NULL);
388 if (dstSect == NULL) {
391 "Can't find destination section for address: "
393 " of adress space: " +
411 }
else if (dstSect->
type() == Section::ST_DATA ||
412 dstSect->
type() == Section::ST_LEDATA ||
413 dstSect->
type() == Section::ST_UDATA) {
418 Word byteOffset = uDataSect->
MAUsToBytes(dstIndex);
427 newReloc->
setType(RelocElement::RT_SELF);
461 if (currSect->
type() == Section::ST_DATA ||
462 currSect->
type() == Section::ST_LEDATA ||
463 currSect->
type() == Section::ST_UDATA) {
550 for (std::map<std::string, UValue>::iterator
554 std::string name = (*iter).first;
555 UValue address = (*iter).second;
563 "Invalid procedure declaration: " +
576 procedSym->
setBinding(SymbolElement::STB_LOCAL);
607 if (relocSect == NULL) {
609 Section::createSection(Section::ST_RELOC));
613 relocSect->
setLink(symbolSect);
647 }
else if (currSect->
type() == Section::ST_DATA ||
648 currSect->
type() == Section::ST_LEDATA ||
649 currSect->
type() == Section::ST_UDATA) {
710 "Defined expression value (" +
712 ") does not match with resolved (" +
TPEF::SymbolElement * createSymbolWithReference(InternalLabel *currLabel, TPEF::Section *ownerSection)
virtual Word lengthInMAUs() const
bool isMinus
Is offset minus.
ASpaceElement * aSpace() const
void setReference(Chunk *aReference)
TPEF::Binary & bin_
For finding sections containing relocated elements.
bool hasValue
Is resolved value defined in struct.
void commitLastRelocations()
virtual SectionType type() const =0
Returns SectioType of actual section instance.
UValue value(std::string &name)
void addSection(Section *section)
void setCause(const Exception &cause)
MachineResourceManager & resources_
Common resources of TPEF.
void addProcedure(std::string &name, UValue value)
TPEF::StringSection * stringSection()
std::string label
Name of the label.
Section * section(Word index) const
TPEF::Section * findSectionByAddress(InternalLabel *currLabel)
Section * referencedSection() const
LabelManager(TPEF::Binary &bin, MachineResourceManager &resources, AssemblyParserDiagnostic *parent)
void writeProcedureSymbols(TPEF::CodeSection *codeSect, TPEF::SymbolSection *symbolSect, TPEF::StringSection *strings)
Word sectionCount() const
TPEF::SectionElement * location
Element that is reloacted.
virtual Word MAUsToBytes(Word mauCount) const
void setBinding(SymbolBinding aBinding)
static std::string toString(const T &source)
UValue resolveExpressionValue(UValue asmLineNumber, LiteralOrExpression &litOrExpr)
void setReference(InstructionElement *aReference)
TPEF::Section * locationSect
Section where relocated immediate or chunk is stored.
UValue value
Resolved value.
#define assert(condition)
virtual void addElement(SectionElement *element)
void addRelocation(TPEF::Section &locationSect, TPEF::SectionElement &location, TPEF::ASpaceElement &dstASpace, UValue destination, UValue bitWidth)
TPEF::ASpaceElement * dstASpace
Address space of destination address.
#define abortWithError(message)
void setCodeFileLineNumber(int lineNum)
void setType(RelocType aType)
TPEF::RelocSection * findOrCreateRelocationSection(InternalRelocation *currReloc, TPEF::SymbolSection *symbolSect)
UValue value
Address where label is located.
Chunk * string2Chunk(const std::string &str)
void setSection(Section *aSect)
std::set< InternalRelocation * > uncommittedRelocs_
Uncommitted relocations.
std::string aSpaceName(std::string &labelName)
void addLabel(TPEF::ASpaceElement &aSpace, std::string &name, UValue value)
InstructionElement & instruction(Word index) const
void setChunked(bool isChunked)
void setSymbol(SymbolElement *aSymbol)
void setGlobal(std::string &labelName)
void setName(Chunk *aName)
void setLocation(SectionElement *aLocation)
std::string name
Name of the label.
TPEF::Section * findRelocationDstSection(InternalRelocation *currReloc)
void removeLabel(std::string &name)
std::string errorMessage() const
std::set< std::string > globals_
Names of global symbols.
TPEF::ASpaceElement & aSpaceElement(std::string &labelName)
TPEF::ASpaceElement * aSpace
Address space of the label.
UValue destination
Destination address.
Word instructionCount() const
void setASpace(const ReferenceManager::SafePointer *addrSpace)
void setAbsolute(bool anAbsoluteness)
void setLink(const ReferenceManager::SafePointer *aLink)
void setASpace(ASpaceElement *anASpace)
UValue offset
Value of offset.
UValue bitWidth
Number of bits that are used to store the value.
TPEF::ASpaceElement * undefinedAddressSpace()
Expression expression
If expression the expression, Otherwise not used.
bool hasOffset
Is offset defined.
void setDestination(SectionElement *aDestination)
SymbolMap labels_
Contains stored symbols by their name.
void setReferencedSection(Section *section)
virtual bool isCodeSection() const
std::map< std::string, UValue > procedures_
Names and addresses of procedure starts.
virtual Chunk * chunk(SectionOffset offset) const
AddressImage startingAddress() const
void clearLastRelocations()
std::set< InternalRelocation * > relocs_
Added relocations.