Skip to content
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

Improper translation to Jimple in scenarios involving temporary variables #2085

Open
DeepakUniAdel opened this issue Jun 6, 2024 · 0 comments

Comments

@DeepakUniAdel
Copy link

The issue is for the following Java code :

int bitValue = 0;
for (int j = 0; j < 32; j++)
{
bitValue ^= (help >>> j) & 1;
}

simple generated is :
(34) $j = 0
(35) $j = 0
(36) if $j >= 32
(37) $stack24 = $help >>> $j
(38) $stack25 = $stack24 & 1
(39) $j = $j ^ $stack25
(40) $j = $j + 1
(41) goto

Where the variable "bitValue" is completely replaced with a temporary variable "I" twice.
The same happens when trying to build Jimple out of the code:

byte[] rv = new byte[size];
int offSet = 0;
for(int i = 0; i != arrays.length; ++i) {
System.arraycopy(arrays[i], 0, rv, offSet, arrays[i].length);
offSet += arrays[i].length;
}

    return rv;

(10) $i = newarray (byte)[$size]
(11) $offSet = 0
(12) $i = 0
(13) $stack6 = lengthof $arrays
(14) if $i == $stack6
(15) $stack9 = $arrays[$i]
(16) $stack7 = $arrays[$i]
(17) $stack8 = lengthof $stack7
(18) staticinvoke <java.lang.System: void arraycopy(java.lang.Object,int,java.lang.Object,int,int)>($stack9, 0, $i, $offSet, $stack8)
(19) $stack10 = $arrays[$i]
(20) $stack11 = lengthof $stack10
(21) $offSet = $offSet + $stack11
(22) $i = $i + 1

here again the variable "rv" is replaced with temporary variable "I". Kindly check if this issue is caused due to an error in implementation of the Jimple data structures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant