zhangwenan / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

debug info '.param' can not be found in the outputs of 2.0.3 version, but the similar exits in 1.4.0 version #201

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I. What seems to be the problem?
Jasper: debug info '.param' can not be found in the outputs of 2.0.3 version, 
but the similar  exits in 1.4.0 version

II. What is the exact smali/baksmali command that you ran?
Jasper:
 The ok and not ok commands are below. Both jar file exits there.
 (1) ok: java -jar ~/Downloads/baksmali-1.4.jar -o baksmali-1.4 Hello.dex 
 (2) not ok: java -jar ~/Downloads/baksmali-2.0.3.jar -o baksmali-2.0.3 Hello.dex

III. What version of smali/baksmali are you using? What rom are you working
from?
Jasper:
 (1) ok is 1.4.0, not ok is 2.0.3.
 (2) no rom. Test for a simple java code.

IV. What is the airspeed velocity of an unladen swallow?

V. Please provide any additional information below: error messages, symptoms,
etc.

Jasper :
The process is below, and I archive all of them ( code, jars, dex ) in a 
.tar.bz2 file, attach it.
I test it in a dex file gengerate by Eclipse. All messages exits in output 
files. 
That's all, Thank you.

1. run command 

 (1. javac Hello.java
 (2. dx --dex --output=Hello.dex Hello.class
 (3. java -jar ~/Downloads/baksmali-1.4.jar -o baksmali-1.4 Hello.dex 
 (4. java -jar ~/Downloads/baksmali-2.0.3.jar -o baksmali-2.0.3 Hello.dex

2. the issue is that 'param' can not be found in ./baksmali-2.0.3/ that was 
generated by baksmali-2.0.3.

$ grep param . -r
./baksmali-1.4/Hello.smali:    .parameter
./baksmali-1.4/Hello.smali:    .parameter
./baksmali-1.4/Hello.smali:    .parameter

3. tools version
 (1. ~$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
 (2. ~$ dx --version
dx version 1.8

Original issue reported on code.google.com by lixingh...@gmail.com on 11 Feb 2014 at 10:00

Attachments:

GoogleCodeExporter commented 9 years ago
I'm confused. What does jasper have to do with the output of baksmali?

And yes, the syntax of the parameter info changed in 2.*. This is documented at 
https://code.google.com/p/smali/wiki/SmaliBaksmali20

Original comment by jesusfreke@jesusfreke.com on 11 Feb 2014 at 6:49

GoogleCodeExporter commented 9 years ago
Sorry for that. Jasper is my name.
I put it there as a tag to distinguish words between the question and my 
answer, then when I want wo find something, just ctrl+f to find jasper. 
otherwise I have to scroll the mouse wheel to find something.

now I'm learning Reverse Engineering on Android. and want to know how to use 
disassembler tools. 
then I find that my outputs lose the syntax of the parameter info, the other 
one's have the syntax. 
I check what we do are different. it is the baksmali version. 
mine is 2.0.3, his is 1.4.0.

The java code Hello.java is simple :

public class Hello 
{
    public int foo (int a, int b)
    {
        return (a + b) * (a - b);
    }

    public static void main(String [] argc)
    {
        Hello hello = new Hello();
        System.out.println(hello.foo(5, 3));
    }
}

Generate dex file Hello.dex by java and dx utility. then disassemble Hello.dex 
to Hello.smali. I focus on the translation of method foo. the generation of 
baksmali2.0.3 is below, which lose the syntax of the parameter info

# virtual methods
.method public foo(II)I
    .registers 5

    .prologue
    .line 5
    add-int v0, p1, p2

    sub-int v1, p1, p2

    mul-int/2addr v0, v1

    return v0
.end method

and the baksmali1.4.0 is below, which has the syntax of the parameter info.

# virtual methods
.method public foo(II)I
    .registers 5
    .parameter
    .parameter

    .prologue
    .line 5
    add-int v0, p1, p2

    sub-int v1, p1, p2

    mul-int/2addr v0, v1

    return v0
.end method

I don't know why they are different, so post the issue.

Original comment by lixingh...@gmail.com on 12 Feb 2014 at 2:25

GoogleCodeExporter commented 9 years ago
Ah, ok. Jasper is also the name of a java (not dalvik) bytecode disassembler, 
so I thought that's what you were referring to. 
(http://www.angelfire.com/tx4/cus/jasper/)

And yes, the .parameter directives that 1.4.0 output in that case conveyed no 
meaning. In 2.* I tightened up the logic for when a .param directive is 
generated, so that they don't get generated in cases like these, where they 
contain no information.

In general, the .param directive is used to specify a parameter name and/or any 
annotations associated with the parameter. If there is no name or annotations 
for a parameter in the dex file, then baksmali 2.* won't output a .param 
directive.

Original comment by jesusfreke@jesusfreke.com on 12 Feb 2014 at 2:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Yeah, I know it. 

Thank you very much. 

:)

Original comment by lixingh...@gmail.com on 12 Feb 2014 at 9:21