binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

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

Open leishen opened this issue 9 years ago • 8 comments

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.

leishen avatar Mar 03 '16 01:03 leishen

dup of #75 ?

crowell avatar Mar 22 '16 02:03 crowell

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".

psifertex avatar Apr 20 '16 02:04 psifertex

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.

fuzyll avatar Feb 28 '24 00:02 fuzyll

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

BlasterXiao avatar Jul 08 '24 12:07 BlasterXiao

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?

psifertex avatar Jul 08 '24 13:07 psifertex

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

BlasterXiao avatar Jul 10 '24 07:07 BlasterXiao

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.

psifertex avatar Jul 10 '24 13:07 psifertex

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.

BlasterXiao avatar Jul 11 '24 03:07 BlasterXiao

@BlasterXiao as of dev 8224 users can now select to display "automatic block labels" which is just a fancy word for saying a placeholder label. You can enable it in the views hamburger menu "Block Labels->Always Show". Lastly we also are now showing the labels at MLIL and HLIL as well as fixed a few rendering bugs at disassembly and LLIL.

I am attaching a video to illustrate the improvements to the block annotations. This is with a jump table you get the idea.

https://github.com/user-attachments/assets/a27d4716-7c2a-4b1e-8857-a1a264acd9fe

I don't know if we should close this issue as IDA has another part where it will only show the "loc_" placeholder labels if the block is taken by address (like in the case of a jump target). We may want to add that as another block label rendering option, however that may require rendering changes related to the CodeRelativeAddressToken token.

emesare avatar Sep 04 '25 00:09 emesare