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

Function analysis regression #14157

Closed
davidpolverari opened this issue May 25, 2019 · 4 comments · Fixed by #14162
Closed

Function analysis regression #14157

davidpolverari opened this issue May 25, 2019 · 4 comments · Fixed by #14162

Comments

@davidpolverari
Copy link
Contributor

@davidpolverari davidpolverari commented May 25, 2019

On the latest commits, r2 -dA or using aaa after loading a file on debugger doesn't resolve function names to addresses.

It seems 680340c is the offending commit on this case, as everything was working normally on the previous commit (3e3d97b).

Work environment

Questions Answers
OS/arch/bits (mandatory) Debian 9 (stretch) amd64
File format of the file you reverse (mandatory) ELF
Architecture/bits of the file (mandatory) x86/64
r2 -v full output, not truncated (mandatory) radare2 3.6.0-git 22430 @ linux-x86-64 git.3.5.1-88-g7d449419b commit: 7d44941 build: 2019-05-25__15:20:05

Expected behavior

$ r2 -dA /bin/true
Process with PID 29761 started...
= attach 29761 29761
bin.baddr 0x55fec6530000
Using 0x55fec6530000
asm.bits 64
[x] Analyze all flags starting with sym. and entry0 (aa)
[Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
[x] Analyze function calls (aac)
[Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
[x] find and analyze function preludes (aap)
[x] Analyze len bytes of instructions for references (aar)
[x] Check for objc references
[x] Check for vtables
[TOFIX: aaft can't run in debugger mode.ions (aaft)
[x] Type matching analysis for all functions (aaft)
[x] Use -AA or aaaa to perform additional experimental analysis.
 -- Save your projects with 'Ps <project-filename>' and restore then with 'Po <project-filename>'
[0x7f5890a35c20]> s main
Cannot seek to unknown address 'main'
[0x7f5890a35c20]> 

Actual behavior

$ r2 -dA /bin/true
Process with PID 29761 started...
= attach 29761 29761
bin.baddr 0x55fec6530000
Using 0x55fec6530000
asm.bits 64
[x] Analyze all flags starting with sym. and entry0 (aa)
[Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
[x] Analyze function calls (aac)
[Warning: Invalid range. Use different search.in=? or anal.in=dbg.maps.x
[x] find and analyze function preludes (aap)
[x] Analyze len bytes of instructions for references (aar)
[x] Check for objc references
[x] Check for vtables
[TOFIX: aaft can't run in debugger mode.ions (aaft)
[x] Type matching analysis for all functions (aaft)
[x] Use -AA or aaaa to perform additional experimental analysis.
 -- Save your projects with 'Ps <project-filename>' and restore then with 'Po <project-filename>'
[0x7f5890a35c20]> s main
[0x<address_of_main>]> 

Steps to reproduce the behavior

  • Call r2 to debug the file and analyze it;
  • Try to seek the position of a well known function in the file.
@radare

This comment has been minimized.

Copy link
Collaborator

@radare radare commented May 26, 2019

@GustavoLCR

This comment has been minimized.

Copy link
Member

@GustavoLCR GustavoLCR commented May 26, 2019

@radare This seems to fix it. I never touched bin before so i don't know what I'm doing

diff --git a/libr/bin/bin.c b/libr/bin/bin.c
index 4b98eebf8..978331633 100644
--- a/libr/bin/bin.c
+++ b/libr/bin/bin.c
@@ -354,6 +354,7 @@ R_API bool r_bin_open_io(RBin *bin, RBinOptions *opt) {
        bin->file = fname;
        opt->sz = R_MIN (file_sz, opt->sz);
        ut64 seekaddr = is_debugger? opt->baseaddr: opt->loadaddr;
+#if 0
        if (seekaddr > 0 && seekaddr != UT64_MAX) {
                // slice buffer if necessary
                RBuffer *nb = r_buf_new_slice (buf, seekaddr, opt->sz);
@@ -362,6 +363,7 @@ R_API bool r_bin_open_io(RBin *bin, RBinOptions *opt) {
                        buf = nb;
                }
        }
+#endif
        if (bin->use_xtr && !opt->pluginname && (st64)opt->sz > 0) {
                // XXX - for the time being this is fine, but we may want to
                // change the name to something like

@radare

This comment has been minimized.

Copy link
Collaborator

@radare radare commented May 26, 2019

@radare

This comment has been minimized.

Copy link
Collaborator

@radare radare commented May 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.