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

Prevent axg* from erasing important function offset information that is retained in axg and axgj #17363

Open
notfoundry opened this issue Jul 27, 2020 · 2 comments
Labels
json Parsing and producing JSON format RGraph test-required

Comments

@notfoundry
Copy link

Is your feature request related to a problem? Please describe.
I am trying to parse the graph built by axg outside of r2. It looks like axg* produces output in the exact format that many graph libraries expect (named nodes, and edges between named nodes), which is fantastic! However, while axg and axgj output the exact point in a function where a reference exists, which is necessary to actually do anything practical with the data, axg* erases that information and replaces it with the start address of the function instead, making the output useless for anything beyond trivial function-level tracing.

Describe the solution you'd like
Instead of only creating nodes and edges with function addresses in axg*, it would be convenient and consistent to output the same instruction-level addresses as axg and axgj. If backwards compatibility is a concern, maybe behind a flag like f?

Describe alternatives you've considered
I've tried to solve the original problem through axgj, and even though it wasn't difficult to write the code, axgj seems like it has a bug causing malformed JSON missing large chunks of information to be produced from large graphs. I also started working on a parser for the output of axg, but it required a non-trivial whitespace-sensitive parser to extract information from it, which seemed like it would be a major pain to use. Writing an extension to r2 is the last alternative I considered, but it seemed that it would be more helpful to everybody using r2 who might run into these issues to have something like this available publicly.

Additional context
Development is being done with the latest r2 version from git, as of the time of writing.

@karliss
Copy link
Contributor

karliss commented Jul 28, 2020

R2 has multiple graph output formats you can see them using ag?.
axg* outputs it using r2 commands, that's a format with very specific purpose and not for consumption by other tools.
For analysis using scripts you should use JSON ouptut. If there are bugs causing it to be malformed then those need to be fixed.

Most instructions reference no more than one address drawing such graph would result in a bunch of spikey balls and would not be much better than displaying the same information in a table "address being referenced" -> "number of times address was referenced". That's likely a reason why axg contains information about function -> address being referenced instead.

What you actually want might be axj command which list all the references. It seems to use the address of instruction referencing things not function since it isn't designed for drawing things.

@XVilka XVilka added RGraph json Parsing and producing JSON format test-required labels Jul 29, 2020
@XVilka
Copy link
Contributor

XVilka commented Jul 29, 2020

Please provide a small reproducer for the bug you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
json Parsing and producing JSON format RGraph test-required
Projects
None yet
Development

No branches or pull requests

3 participants