mgbdis icon indicating copy to clipboard operation
mgbdis copied to clipboard

Add ability to add comments through the sym file

Open rbong opened this issue 3 years ago • 5 comments

I'm working on a large disassembly project and I'd like to be able to share it and add comments, but I can't include the disassembled binary with anything I share for licensing reasons. This branch adds the ability to insert comments into the assembly file via specially formatted comments in the symbol file.

There are some restrictions. You currently can't put comments before labels, only after. You cannot put comments at the end of lines. If a comment is in the middle of data or an instruction, the comment is just placed before the line instead of breaking anything up.

This was the simplest solution I could find. Please let me know if you'd like me to change how comments are added, if you'd like this change at all.

rbong avatar Jan 05 '21 05:01 rbong

Hey, sorry just saw this PR! I think it would be great to include the abililty to add comments to the disassembly.

Do you have any ideas how we might support comments being (optionally) placed before labels, and at the end of lines?

Also I'm not sure if your current PR includes it, but it would be good to be able to support multiline comments, and have the option for a comment to be indented to align with source code.

mattcurrie avatar Feb 08 '21 23:02 mattcurrie

Do you have any ideas how we might support comments being (optionally) placed before labels, and at the end of lines?

Maybe options could go before the address?

;; opt1,opt2 02:791a

This is keeping with the options for labels, ex. the options w128,pe4 in .image:500:w128,pe4, but since there's no label to attach the options to, before the address is the only special area where options can be added.

You could also add options right after the address, but this is maybe a little misleading that this has something to do with the address of the comment:

;; 02:791a:opt1,opt2

Let me know which one you like better or if you have another idea.

it would be good to be able to support multiline comments

What is the syntax for multiline comments in this flavor of sym files, or is there one?

Concerning conflicts, I'll fix those up when I get a chance. There's also a bug or two that I've encountered while disassembling.

rbong avatar Feb 13 '21 19:02 rbong

Hey, on my master branch I now have the ability to overwrite left and right operands using the following format:

;; 00:0000:l_op LEFT_OPERAND
;; 00:0000:r_op RIGHT_OPERAND

Might want to consider future cases like this when thinking about how the syntax is going to work. Maybe something like this will work well:

;; 00:0000:(type):(options) (body)

Examples:

;; 00:0000:comment This is a comment
;; 00:0000 This is a comment (uses default type)
;; 00:0000:comment:before_label This is a comment that goes before the label (has an option)
;; 00:0000::before_label This is a comment before the label (uses default type, has options)

Not sure how to do multi-line comments still.

rbong avatar Mar 26 '21 11:03 rbong

I think the functionality present as-is is good enough, and is worth merging after rebasing. Sure, it may be improvable, but such additions can always be merged in a second wave, instead of this never being merged at all ^^

ISSOtm avatar Jul 01 '21 14:07 ISSOtm

Yeah, my only concern is merging syntax that later has to be changed. It seems like it's good though so if @mattcurrie is happy I can fix conflicts and it should be good to merge.

rbong avatar Jul 05 '21 19:07 rbong