RFC: Annotate immediates in x86 disassembly
Richard Earnshaw (foss)
Richard.Earnshaw@arm.com
Thu Apr 23 13:01:26 GMT 2026
On 23/04/2026 10:13, Nick Clifton wrote:
> Hi Michael,
>
>>> 400419: bf 18 30 40 00 mov $0x403018 [func1],%edi
>
>> I think it's helpful, but may I use the bike-shed opportunity here?
>
> Of course...
>
>> I
>> would prefer if the disassembler output (even with the option, but with
>> --no-addresses --show-raw-insn) would be roughly copy-n-pastable to the
>> assembler. That would mean putting any annotations (and there may be more
>> in the future?) after a comment-introducer. Like:
>>
>> 400419: bf 18 30 40 00 mov $0x403018,%edi # [func1]
>
> Ah - yes I did think about this. But as far as I can see the current code
> in i386-dis.c does not have any way to queue up comments to be displayed at
> the end of the line. So that would mean either adding the framework to do
> so, or adding yet another walk over all of the operands, once the disassembly
> proper has been displayed. Since the feature is gated by the -Mannotate option
> it seemed to me that doing either of these things would needlessly complicate
> the code.
>
> But ... I agree that it would be nice, and if, as you suggest, there might be
> more annotations to come in the future then it would make sense to code the
> framework for them now. Let me have a little investigation...
>
> Cheers
> Nick
>
We somehow do this for function calls and jump instructions.
But to bikeshed further, I've sometimes pondered whether the disassembler should produce some structured data output which a generic output formatter can then grok. This would be able to handle this and coloured output more sensibly since we've improved the abstraction.
The problem, of course, is that such an approach would be a LOT more work.
R.
More information about the Binutils
mailing list