My Project
sleighbase.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 #ifndef __SLEIGHBASE__
19 #define __SLEIGHBASE__
20 
21 #include "translate.hh"
22 #include "slghsymbol.hh"
23 
29 class SleighBase : public Translate {
30  static const int4 SLA_FORMAT_VERSION;
31  vector<string> userop;
32  map<VarnodeData,string> varnode_xref;
33 protected:
38  uint4 numSections;
39  void buildXrefs(vector<string> &errorPairs);
40  void reregisterContext(void);
41  void restoreXml(const Element *el);
42 public:
43  SleighBase(void);
44  bool isInitialized(void) const { return (root != (SubtableSymbol *)0); }
45  virtual ~SleighBase(void) {}
46  virtual void addRegister(const string &nm,AddrSpace *base,uintb offset,int4 size);
47  virtual const VarnodeData &getRegister(const string &nm) const;
48  virtual string getRegisterName(AddrSpace *base,uintb off,int4 size) const;
49  virtual void getAllRegisters(map<VarnodeData,string> &reglist) const;
50  virtual void getUserOpNames(vector<string> &res) const;
51 
52  SleighSymbol *findSymbol(const string &nm) const { return symtab.findSymbol(nm); }
53  SleighSymbol *findSymbol(uintm id) const { return symtab.findSymbol(id); }
54  SleighSymbol *findGlobalSymbol(const string &nm) const { return symtab.findGlobalSymbol(nm); }
55  void saveXml(ostream &s) const;
56 };
57 
58 #endif
uint4 numSections
Number of named sections.
Definition: sleighbase.hh:38
A region where processor data is stored.
Definition: space.hh:73
virtual void getAllRegisters(map< VarnodeData, string > &reglist) const
Get a list of all register names and the corresponding location.
Definition: sleighbase.cc:129
SleighSymbol * findSymbol(uintm id) const
Find a specific SLEIGH symbol by id.
Definition: sleighbase.hh:53
virtual string getRegisterName(AddrSpace *base, uintb off, int4 size) const
Get the name of a register given its location.
Definition: sleighbase.cc:103
bool isInitialized(void) const
Return true if this is initialized.
Definition: sleighbase.hh:44
Definition: slghsymbol.hh:70
SymbolTable symtab
The SLEIGH symbol table.
Definition: sleighbase.hh:35
virtual const VarnodeData & getRegister(const string &nm) const
Get a register as VarnodeData given its name.
Definition: sleighbase.cc:92
Common core of classes that read or write SLEIGH specification files natively.
Definition: sleighbase.hh:29
SleighBase(void)
Construct an uninitialized translator.
Definition: sleighbase.cc:20
SleighSymbol * findGlobalSymbol(const string &nm) const
Find a specific global SLEIGH symbol by name.
Definition: sleighbase.hh:54
virtual void getUserOpNames(vector< string > &res) const
Get a list of all user-defined pcode ops.
Definition: sleighbase.cc:135
Definition: slghsymbol.hh:23
The interface to a translation engine for a processor.
Definition: translate.hh:293
virtual ~SleighBase(void)
Destructor.
Definition: sleighbase.hh:45
void restoreXml(const Element *el)
Read a SLEIGH specification from XML.
Definition: sleighbase.cc:180
An XML element. A node in the DOM tree.
Definition: xml.hh:150
void reregisterContext(void)
Reregister context fields for a new executable.
Definition: sleighbase.cc:67
SubtableSymbol * root
The root SLEIGH decoding symbol.
Definition: sleighbase.hh:34
uint4 unique_allocatemask
Bits that are guaranteed to be zero in the unique allocation scheme.
Definition: sleighbase.hh:37
void buildXrefs(vector< string > &errorPairs)
Build register map. Collect user-ops and context-fields.
Definition: sleighbase.cc:31
uint4 maxdelayslotbytes
Maximum number of bytes in a delay-slot directive.
Definition: sleighbase.hh:36
void saveXml(ostream &s) const
Write out the SLEIGH specification as an XML <sleigh> tag.
Definition: sleighbase.cc:143
Classes for disassembly and pcode generation.
virtual void addRegister(const string &nm, AddrSpace *base, uintb offset, int4 size)
Add a named register to the model for this processor.
Definition: sleighbase.cc:85
Definition: slghsymbol.hh:561
Data defining a specific memory location.
Definition: pcoderaw.hh:33
SleighSymbol * findSymbol(const string &nm) const
Find a specific SLEIGH symbol by name in the current scope.
Definition: sleighbase.hh:52