Variables on the stack are not identified by bp/sp+<offset> anymore, but by their address from the bottom of the stack frame (RzStackAddr), independent of how they are accessed. So now there are only two kinds of variables: stack and register. This required some major refactoring and other changes: * RzAnalysisVar.isarg was removed. Whether a variable is an argument is now specified implicitly by its storage location. * Varsub of struct fields had to be rewritten so fields can be queried by arbitrary stack addresses using the recently introduced sp tracking, as the old approach to fill a list with all fields would not work anymore. * analysis.vars.stackname was removed, new behavior is more similar to this being true before. * Variables will not be created at stack+0 now, because the return address is there. Before, vars were only created sometimes in such cases. * Variables created from bp offsets in x86 are not deleted anymore if the function's bp_frame is false (see removed rz_analysis_function_delete_vars_by_kind(fcn, RZ_ANALYSIS_VAR_KIND_BPV); calls). This may lead to some false-positive detected variables. Whether this really is a practical issue is yet to be seen. At least there are no meaningful tests that are broken by this. * Applying variables from dwarf needed some fixes for determining the correct stack locations of variables in order to write meaningful tests. The handling is still not entirely correct for all possibilities of dwarf info, but at least the changed/added test cases are right and serve as a reference for future changes. * Projects version 11 is introduced. * afvb commands have been removed, afvs now handles all stack vars.
130 lines
3.2 KiB
Text
130 lines
3.2 KiB
Text
NAME=att subrel
|
|
FILE=bins/mach0/mac-ls
|
|
CMDS=<<EOF
|
|
e asm.syntax=att
|
|
e asm.lines.bb=0
|
|
e asm.bytes=0
|
|
e asm.comments=false
|
|
pd 20
|
|
EOF
|
|
EXPECT=<<EOF
|
|
;-- main:
|
|
;-- entry0:
|
|
;-- func.100001058:
|
|
0x100001058 pushq %rbp
|
|
0x100001059 movq %rsp, %rbp
|
|
0x10000105c pushq %r15
|
|
0x10000105e pushq %r14
|
|
0x100001060 pushq %r13
|
|
0x100001062 pushq %r12
|
|
0x100001064 pushq %rbx
|
|
0x100001065 subq $0x648, %rsp
|
|
0x10000106c movq %rsi, %rbx
|
|
0x10000106f movl %edi, %r14d
|
|
0x100001072 leaq -0x640(%rbp), %rax
|
|
0x100001079 movq %rax, -0x648(%rbp)
|
|
0x100001080 testl %r14d, %r14d
|
|
0x100001083 jg 0x10000108a
|
|
0x100001085 callq sym.func.100004401
|
|
0x10000108a leaq section.4.__TEXT.__cstring, %rsi
|
|
0x100001091 xorl %edi, %edi
|
|
0x100001093 callq sym.imp.setlocale
|
|
0x100001098 movl $1, %r13d
|
|
0x10000109e movl $1, %edi
|
|
EOF
|
|
RUN
|
|
|
|
NAME=att varsub
|
|
FILE=bins/mach0/mac-ls
|
|
CMDS=<<EOF
|
|
af
|
|
e asm.syntax=att
|
|
e asm.var=0
|
|
e asm.lines.bb=0
|
|
e asm.bytes=0
|
|
e asm.comments=false
|
|
pd 20
|
|
EOF
|
|
EXPECT=<<EOF
|
|
;-- entry0:
|
|
;-- func.100001058:
|
|
/ int main (int argc, char **argv, char **envp);
|
|
| 0x100001058 pushq %rbp
|
|
| 0x100001059 movq %rsp, %rbp
|
|
| 0x10000105c pushq %r15
|
|
| 0x10000105e pushq %r14
|
|
| 0x100001060 pushq %r13
|
|
| 0x100001062 pushq %r12
|
|
| 0x100001064 pushq %rbx
|
|
| 0x100001065 subq $0x648, %rsp
|
|
| 0x10000106c movq %rsi, %rbx
|
|
| 0x10000106f movl %edi, %r14d
|
|
| 0x100001072 leaq var_648h, %rax
|
|
| 0x100001079 movq %rax, var_650h
|
|
| 0x100001080 testl %r14d, %r14d
|
|
| 0x100001083 jg 0x10000108a
|
|
| 0x100001085 callq sym.func.100004401
|
|
| 0x10000108a leaq section.4.__TEXT.__cstring, %rsi
|
|
| 0x100001091 xorl %edi, %edi
|
|
| 0x100001093 callq sym.imp.setlocale
|
|
| 0x100001098 movl $1, %r13d
|
|
| 0x10000109e movl $1, %edi
|
|
EOF
|
|
RUN
|
|
|
|
NAME=att varsub 2
|
|
FILE=bins/elf/varsub
|
|
CMDS=<<EOF
|
|
aa; s main
|
|
e asm.syntax=att
|
|
e asm.var=0
|
|
e asm.lines.bb=0
|
|
e asm.bytes=0
|
|
e asm.comments=false
|
|
pdf
|
|
EOF
|
|
EXPECT=<<EOF
|
|
/ int main (int argc, char **argv, char **envp);
|
|
| 0x004004a6 pushq %rbp
|
|
| 0x004004a7 movq %rsp, %rbp
|
|
| 0x004004aa movq var_10h + 0x10, %rax
|
|
| 0x004004af movq var_10h, %rax
|
|
| 0x004004b4 movq var_10h + 0x10, %rax
|
|
| 0x004004b8 movq var_10h, %rax
|
|
| 0x004004bc movq arg_10h, %rax
|
|
| 0x004004c1 movq var_20h, %rax
|
|
| 0x004004c6 movq arg_10h, %rax
|
|
| 0x004004ca movq var_20h, %rax
|
|
| 0x004004ce leave
|
|
\ 0x004004cf retq
|
|
EOF
|
|
RUN
|
|
|
|
NAME=att varsub 2 with asm.sub.varonly disabled
|
|
FILE=bins/elf/varsub
|
|
CMDS=<<EOF
|
|
aa; s main
|
|
e asm.syntax=att
|
|
e asm.var=0
|
|
e asm.lines.bb=0
|
|
e asm.bytes=0
|
|
e asm.comments=false
|
|
e asm.sub.varonly=false
|
|
pdf
|
|
EOF
|
|
EXPECT=<<EOF
|
|
/ int main (int argc, char **argv, char **envp);
|
|
| 0x004004a6 pushq %rbp
|
|
| 0x004004a7 movq %rsp, %rbp
|
|
| 0x004004aa movq var_10h + 0x10(%rsp), %rax
|
|
| 0x004004af movq var_10h(%rsp), %rax
|
|
| 0x004004b4 movq var_10h + 0x10(%rbp), %rax
|
|
| 0x004004b8 movq var_10h(%rbp), %rax
|
|
| 0x004004bc movq arg_10h(%rsp), %rax
|
|
| 0x004004c1 movq var_20h(%rsp), %rax
|
|
| 0x004004c6 movq arg_10h(%rbp), %rax
|
|
| 0x004004ca movq var_20h(%rbp), %rax
|
|
| 0x004004ce leave
|
|
\ 0x004004cf retq
|
|
EOF
|
|
RUN
|