What are "ins" and "outs" in the Dalvik butt codec?

In the dex code (for example, as generated by the dexdump tool), for each method definition, I see "ins" and "outs" in addition to other metadata like "registers", "insns size".

I am using dex code to inject new registers. The toolkit is not working, and I suspect that I might have to change the ins and outs values ​​depending on the number of new registers I add.

So my question is, what are those "ins" and "outs"?

(fyi: I'm using dexlib2 for this.)

+3


source to share


1 answer


These fields are documented at http://source.android.com/devices/tech/dalvik/dex-format.html .

ins_size | the number of words of incoming arguments to the method that this code for

outs_size | the number of words of the outgoing argument space required by this code to call the method

ins_size is mostly self-explanatory - it is the number of 32-bit words required to store method arguments (including the implicit "this" argument for non-static methods). All arguments require 1 word, except longs (J) and double (D), which require 2 words.



outs_size is basically the opposite. outs_size must be set large enough to contain arguments for any method invocation that occurs in a method.

If you want to use a dex file without worrying about such details, you can use dexlib2 (a library developed for and used by smali / baksmali to read / write dex files). The library is available in the maven repository , so it's easy to link if you are using gradle / mvn.

+4


source







All Articles