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

Xrefs to THUMB functions from data pointer don't appear #6415

Open
raminri opened this issue Feb 12, 2025 · 4 comments
Open

Xrefs to THUMB functions from data pointer don't appear #6415

raminri opened this issue Feb 12, 2025 · 4 comments
Labels
Component: UI Issue needs changes to the user interface Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround UI: Cross References Issues with the Cross References widget

Comments

@raminri
Copy link

raminri commented Feb 12, 2025

Version and Platform (required):

  • Binary Ninja Version: 4.3.6844
  • OS: Windows
  • OS Version: 10
  • CPU Architecture: x64

Bug Description:
When clicking on a function that has a pointer to it with the bottom bit set (indicating it is a THUMB function), the xref does not show up.

Steps To Reproduce:
I made this simple program for illustrating the issue:

#include <stdio.h>

void foo() {
  printf("foo\n");
}

void bar() {
  printf("bar\n");
}

void (*func_ptr)() = foo;

int main(int argc, const char* argv[]) {
  if (argc > 1)
    func_ptr = bar;
  func_ptr();
  return 0;
}
  1. Open test from attached zip file
  2. Go to func_ptr symbol and set the type to a pointer (I also think binja should be recognizing that this is a pointer automatically)
  3. You should now see void* func_ptr = foo
  4. Go to the foo function and click on the function name to see the xrefs, and see that there are 0 xrefs to the function

Expected Behavior:
I expect to see an xref to func_ptr from foo

Screenshots/Video Recording:
N/A

Binary:
test.zip

Additional Information:
I believe the issue is that the xref system is not accounting for the bottom bit being set in the function pointer, which causes the xref to be missing.

@xusheng6
Copy link
Member

Hi, thx for the bug report! However, I am unable to reproduce it -- if I select the start of the foo function, there is 1 xref showing up as expected

Image

@xusheng6
Copy link
Member

Btw you might wish to test and see if the issue is already fixed on the latest dev

@xusheng6 xusheng6 added the State: Unreproducible Issue could not be reproduced by a developer label Feb 18, 2025
@raminri
Copy link
Author

raminri commented Feb 18, 2025

From your screenshot it seems like you are selecting the first 2 lines of the function rather than the function itself. I've noticed this makes the xref show up. My guess is this is probably because highlighting multiple lines causes xrefs to show up for a range of addresses, which includes the address that has LSB set.

If you select just the foo symbol, the xref won't show up.

Just foo symbol selected (no xref):
Image

First 2 lines of function selected like your screenshot (xref shows up):
Image

I updated to latest dev and retested to confirm this.

@xusheng6
Copy link
Member

From your screenshot it seems like you are selecting the first 2 lines of the function rather than the function itself. I've noticed this makes the xref show up. My guess is this is probably because highlighting multiple lines causes xrefs to show up for a range of addresses, which includes the address that has LSB set.

If you select just the foo symbol, the xref won't show up.

Just foo symbol selected (no xref): Image

First 2 lines of function selected like your screenshot (xref shows up): Image

I updated to latest dev and retested to confirm this.

I see what you are saying. Interestingly, if I think the line of the function header, it actually shows up:

Image

But if I select the address token 0x10424, it does not show up:

Image

I am not super familiar with the thumb arch, I known there has been some similar issues in the past, and I will bring this up with the team

@xusheng6 xusheng6 added Component: Architecture Issue needs changes to an architecture plugin Component: UI Issue needs changes to the user interface UI: Cross References Issues with the Cross References widget Impact: Low Issue is a papercut or has a good, supported workaround Effort: Low Issue should take < 1 week and removed State: Unreproducible Issue could not be reproduced by a developer Component: Architecture Issue needs changes to an architecture plugin labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: UI Issue needs changes to the user interface Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround UI: Cross References Issues with the Cross References widget
Projects
None yet
Development

No branches or pull requests

2 participants