Repository navigation
Replies: 1 comment 5 replies
|
Two separate things.
The CONCAT22 is a decompiler limitation. Reproduced on Ghidra 12.2, x86:LE:16:Real Mode, return in DX:AX as long: gives W/o a stack argument on the first call (or w/o the first call), the same sequence gives Cause: RulePiece2Sext (ruleaction.cc) turns PIECE(x s>> 15, x) into SEXT only when both halves are the same varnode. Here the halves come back from the stack slots where DX and AX were pushed, and at the dtor call each slot gets an INDIRECT, so PIECE sees two different varnodes. Those INDIRECTs are normally dropped for unaliased stack temporaries (Funcdata::opCollapseIndirectsForAlias). But ScopeLocal::isUnmappedUnaliased (varmap.cc) treats every offset between the lowest and highest stack-argument slot of any call in the function as possibly aliased. getval's argument is at -4 and dtor's at -8, so the saved DX/AX at -4/-6 fall inside that span and keep their INDIRECTs. So it shows up whenever registers are saved on the stack inside the span used for call arguments, which is common in 16-bit code. I didn't find an option or type change that avoids it. The fix belongs in isUnmappedUnaliased, e.g. tracking each call's argument range instead of one min/max span. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Why does the 16-bit x86
CWDcommand produce:iVal2 = iVal1 >> 0xf;?
Because its not even correct as
iVal2would be either0or-1(0xffff)In my current situation, the 2 registers (
AX&DX) are pushed onto the stack, whereupon a call to a class destructor (involving its parameters being added to the stack) is made, followed byAX&DXbeing popped and subsequently returned as a single 32-bit value (that, I hasten to add, Ghidra is incapable of rendering nicely, it producesreturn CONCAT22(iVal2,iVal1);instead of justreturn iVar1maybe with a(long)typecast!All reactions