-
Notifications
You must be signed in to change notification settings - Fork 0
Clone introduce operand offset #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,3 +79,4 @@ | |
| *.tgz binary | ||
| *.war binary | ||
| *.zip binary | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -121,6 +121,8 @@ uintb ConstTpl::fix(const ParserWalker &walker) const | |||||
| switch(type) { | ||||||
| case j_start: | ||||||
| return walker.getAddr().getOffset(); // Fill in starting address placeholder with real address | ||||||
| case j_offset: | ||||||
| return walker.getAddr().getOffset(); // Fill in starting address placeholder with real address | ||||||
| case j_next: | ||||||
|
Comment on lines
+124
to
126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
- case j_offset:
- return walker.getAddr().getOffset(); // Fill in starting address placeholder with real address
+ case j_offset:
+ return walker.getOffset(-1); // Fill in operand-offset placeholder with actual operand position🤖 Prompt for AI Agents |
||||||
| return walker.getNaddr().getOffset(); // Fill in next address placeholder with real address | ||||||
| case j_next2: | ||||||
|
|
@@ -350,6 +352,9 @@ void ConstTpl::saveXml(ostream &s) const | |||||
| case j_start: | ||||||
| s << "start\"/>"; | ||||||
| break; | ||||||
| case j_offset: | ||||||
| s << "operand_offset\"/>"; | ||||||
| break; | ||||||
| case j_next: | ||||||
| s << "next\"/>"; | ||||||
| break; | ||||||
|
|
@@ -408,6 +413,9 @@ void ConstTpl::restoreXml(const Element *el,const AddrSpaceManager *manage) | |||||
| else if (typestring=="start") { | ||||||
| type = j_start; | ||||||
| } | ||||||
| else if (typestring=="operand_offset") { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Accept a legacy alias when restoring XML by recognizing both
Suggested change
Why Change? ⭐The change simply extends the existing string comparison to accept a legacy alias ("offset") in addition to the new "operand_offset" token.
|
||||||
| type = j_offset; | ||||||
| } | ||||||
| else if (typestring=="next") { | ||||||
| type = j_next; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,6 +254,8 @@ void SymbolTable::restoreSymbolHeader(const Element *el) | |
| sym = new OperandSymbol(); | ||
| else if (el->getName() == "start_sym_head") | ||
| sym = new StartSymbol(); | ||
| else if (el->getName() == "offset_sym_head") | ||
| sym = new OffsetSymbol(); | ||
| else if (el->getName() == "end_sym_head") | ||
| sym = new EndSymbol(); | ||
| else if (el->getName() == "next2_sym_head") | ||
|
|
@@ -1196,6 +1198,70 @@ void StartSymbol::restoreXml(const Element *el,SleighBase *trans) | |
| patexp->layClaim(); | ||
| } | ||
|
|
||
| OffsetSymbol::OffsetSymbol(const string &nm,AddrSpace *cspc) : SpecificSymbol(nm) | ||
|
|
||
| { | ||
| const_space = cspc; | ||
| patexp = new OperandOffsetValue(); | ||
| patexp->layClaim(); | ||
| } | ||
|
|
||
| OffsetSymbol::~OffsetSymbol(void) | ||
|
|
||
| { | ||
| if (patexp != (PatternExpression *)0) | ||
| PatternExpression::release(patexp); | ||
| } | ||
|
|
||
| VarnodeTpl *OffsetSymbol::getVarnode(void) const | ||
|
|
||
| { // Returns current operand offset as a constant | ||
| ConstTpl spc(const_space); | ||
| ConstTpl off(ConstTpl::j_offset); | ||
| ConstTpl sz_zero; | ||
| return new VarnodeTpl(spc,off,sz_zero); | ||
| } | ||
|
|
||
| void OffsetSymbol::getFixedHandle(FixedHandle &hand,ParserWalker &walker) const | ||
|
|
||
| { | ||
| hand.space = walker.getCurSpace(); | ||
| hand.offset_space = (AddrSpace *)0; | ||
| hand.offset_offset = walker.getAddr().getOffset(); // Get starting address of instruction | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| hand.size = hand.space->getAddrSize(); | ||
| } | ||
|
|
||
| void OffsetSymbol::print(ostream &s,ParserWalker &walker) const | ||
|
|
||
| { | ||
| intb val = (intb) walker.getAddr().getOffset(); | ||
| s << "0x" << std::hex << val << std::dec; | ||
| } | ||
|
Comment on lines
+1226
to
+1239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Operand offset needs operand-relative displacement
🤖 Prompt for AI Agents |
||
|
|
||
| void OffsetSymbol::saveXml(ostream &s) const | ||
|
|
||
| { | ||
| s << "<offset_sym"; | ||
| SleighSymbol::saveXmlHeader(s); | ||
| s << "/>\n"; | ||
| } | ||
|
|
||
| void OffsetSymbol::saveXmlHeader(ostream &s) const | ||
|
|
||
| { | ||
| s << "<offset_sym_head"; | ||
| SleighSymbol::saveXmlHeader(s); | ||
| s << "/>\n"; | ||
| } | ||
|
|
||
| void OffsetSymbol::restoreXml(const Element *el,SleighBase *trans) | ||
|
|
||
| { | ||
| const_space = trans->getConstantSpace(); | ||
| patexp = new OperandOffsetValue(); | ||
| patexp->layClaim(); | ||
| } | ||
|
|
||
| EndSymbol::EndSymbol(const string &nm,AddrSpace *cspc) : SpecificSymbol(nm) | ||
|
|
||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -570,6 +570,9 @@ else if (sym instanceof VarnodeSymbol) { | |||||||||||||
| else if (sym instanceof StartSymbol) { | ||||||||||||||
| // Ignore. We handle inst_start in semantic processing | ||||||||||||||
| } | ||||||||||||||
| else if (sym instanceof OffsetSymbol) { | ||||||||||||||
| // Ignore. We handle inst_start in semantic processing | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+573
to
+575
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment here seems to be a copy-paste error from the
Suggested change
|
||||||||||||||
| else if (sym instanceof EndSymbol) { | ||||||||||||||
| // Ignore. We handle inst_next in semantic processing | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment for
case j_offsetappears to be a copy-paste fromcase j_start. This is misleading as it doesn't mention that this case handles theoperand_offsetsymbol. Please update the comment for clarity.