Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
893 stars 200 forks source link

Allow creation of arbitrary labels (address, basic_block, etc) #185

Open leishen opened 8 years ago

leishen commented 8 years ago

I'd like to request labels for basic blocks. If I have a jump to an address, I'd like to be able to label the address and have that label displayed in the beginning of the block. Similarly, I'd like to be able to add labels for any block whether it has a reference or not. I don't think labels are necessary at the sub-block level, but I do not have a strong opinion on that one way or another.

crowell commented 8 years ago

dup of #75 ?

psifertex commented 8 years ago

I think it's slightly different -- this one is probably best categorized as "allow creation of labels anywhere" which would be a distinct feature from #75 which is probably "add default label to each basic block with address".

fuzyll commented 6 months ago

You can already set a jump target to a name by hitting n on it:

image

...it just doesn't draw the bare symbol that's been created as a label.

Surprisingly, you can also do this for any other address by hitting n on it as well. You can verify that a bare symbol has been made by searching for it in Symbols view (with "Show Data Variables (Local)" on). It just never renders the symbol anywhere.

This is especially unfortunate because this would combo pretty well with our new External Links feature by allowing you to arbitrarily link two locations together. It actually works with this now, you just have to remember which address will navigate you to the other project file when clicked.

EDIT: Just to be clear, I'm not trying to say that bare symbols should be labels, or that anyone should rely on the current functionality I outlined above. Just pointing out some of the things that already exist that get closer to what users want for a future implementer.

BlasterXiao commented 2 months ago

I hope that tag information can be automatically displayed like ida to facilitate static analysis.

psifertex commented 2 months ago

Tags are showed and hovering shows the data value for each tag. Can you be more specific about what you mean? Are you using "tag" instead of "label" here?

BlasterXiao commented 2 months ago

Tags are showed and hovering shows the data value for each tag. Can you be more specific about what you mean? Are you using "tag" instead of "label" here?

What I mean is that it can be changed to be consistent with IDA's labeling operation, or add an option to let users decide whether they want it or not, which can be set in the settings:example: image

psifertex commented 2 months ago

Gotcha. So label would be the term we use in our UI for that element, not tag which is something else:

https://dev-docs.binary.ninja/guide/index.html#tagsbookmarks

Your request is what this issue is tracking.

Can you explain more how this facilitates static analysis for you? You can already click to highlight the destination address which is often faster than scanning to try to find the exact location. Generally we recommend graph view for understand looping logic since it's even quicker to understand structures like that.

That said, I'm not against adding this as a setting we just always like to understand the actual need so we can consider whether there are other ways to solve the problem that are better than what people are used to. No sense in just blindly implementing a feature without better understanding the need.

BlasterXiao commented 2 months ago

When attempting to decompile a segment of assembly instructions, sometimes it is not accurate or effective to rely solely on f5, requiring manual context-based C code decompilation. This is especially necessary for scenarios involving constructs like if...else, for, while, switch, and instruction flattening. In these cases, it's vital to have an intuitive view of the corresponding code fragments and be able to rename labels promptly, facilitating the decompilation process into C code. Labels become particularly crucial and important at this stage. Merely clicking to observe the corresponding addresses makes it challenging to manually decompile a large block of code. Therefore, I hope this feature can be added to aid in learning and research work.