Link to the exact link in Dalvik Verifier

I am writing a Dalvik bytecode toolkit that does some registration for various method invocation records. In particular, on different method invocation sites, I will insert a set of instructions that collect the parameters, put them into an array, Object[]and then pass this to the registration function.

This is good and good, I implemented and walked past all kludges for most applications. But I meet one particularly impenetrable error of the Dalvik verifier:

java.lang.VerifyError: Verifier rejected class io.a.a.g: void io.a.a.g.r() 
failed to verify: void io.a.a.g.r(): [0x570] register v5 has type Reference: 
java.lang.Object but expected Precise Reference: java.lang.String

I looked at the code generated by my tools, and all I do is set the v5 register to an array of objects.

I have a few questions here:

  • What is an exact link and why is it incompatible with links?
  • What does offset mean? [0x570]indicates the middle of the bytecode instruction, so it does not explicitly map to any commands: it is not in the instructions v5.
  • How can I debug this? Ideally, I would like to know what, according to the verifier, should happen, and fix it.

EDIT:

Here's the bytecode dump of the method I'm talking about. https://gist.github.com/kmicinski/c8382f0521b19643bb24379d91c47d36 As you can see, 0x570 is not the beginning of the instruction, and (as far as I can tell) t any place where r5 conflicts with String, where it should be an object.

+4
source share
3 answers

, , Object, String. , , , -, .

, 0x570 ? . , , , r5 , String. -, .

: , , , , v5 Object,

.catch JSONException {:5D8 .. :938} :BDE : BDE

catch v5, , v5 ​​ . :162

:BDE
00000BDE  move-exception      v5
00000BE0  const               v0, 0x00488B36
00000BE6  invoke-static       Logger->logBasicBlockEntry(I)V, v0
00000BEC  goto/16             :162

:162 : .catch ClassNotFoundException {:2E .. :594} :BF0

:Bf0 v5 :A28

:BF0
00000BF0  move-exception      v6
00000BF2  const               v0, 0x00488B3E
00000BF8  invoke-static       Logger->logBasicBlockEntry(I)V, v0
00000BFE  goto/16             :A28

:A28 - , , v5 String. , :AE0, v5 , .

00000AE0  invoke-virtual      StringBuilder->append(String)StringBuilder, v7, v5

0xAE0 0x570, , , , , JesusFreke.

, , , , . , , v5 JSONException , , Object.

+3

0x570, , , . , 0xAE0, , v5.

, , - , v5, , , v5 , 5. , . , , java.lang.Object .

, baksmali --register-info ARGS,DEST,FULLMERGE ( --code-offsets, 0xAE0), 0xAE0 , v5 .

+2

, , , , , , !

@Antimony, , , , v5 ( v5 Object), goto 'da . v5 , .

goto return-void. - Dalvik .

, , , return-void, . , return-void Logger.logMethodExit, , , (:BF0 ) , v5 . ( gen/kill dataflow). , ... Crud.

, , , , !

, :

  • - 2 *

  • - JVM, - Dalvik , , return.

  • , - , , Object ( ).

  • -, , gen/kill, , , , return-* , try.. .

+2

Source: https://habr.com/ru/post/1675385/


All Articles