RFC: Annotate immediates in x86 disassembly

Jiang, Haochen haochen.jiang@intel.com
Thu Apr 23 02:33:37 GMT 2026


> From: Jan Beulich <jbeulich@suse.com>
> Sent: Wednesday, April 22, 2026 6:44 PM
> 
> On 22.04.2026 11:02, Nick Clifton wrote:
> > Hi Guys,
> >
> >    Attached is a small potential patch that adds a new target specific
> >    option to the x86 and x86_64 disassemblers: "-M annotate-immediates".
> >    If enabled immediate operands which match a symbol's value will have
> >    the name of that symbol displayed alongside them.
> >
> >    For example, without the new option a line of disassembly might look
> >    like this:
> >
> >       400419:	bf 18 30 40 00       	mov    $0x403018,%edi
> >
> >    whereas with the option enabled it could look like this:
> >
> >       400419:	bf 18 30 40 00       	mov    $0x403018 [func1],%edi
> >
> >    I find this helpful when looking at code that loads function
> >    addresses into registers for example.
> >
> >    What do you think ?  Would this be a useful addition to the assembler?
> 
> For the disassembler - yes, sure.

It is helpful for sure.

> 
> >    Notes:
> >      * The feature is only enabled when disassembling executables as
> >        the symbolic addresses in object files too often match small
> >        ordinary constants.
> >
> >      * The option parser will accept "-M annotate" or "-M
> >        annotate-immediates" or "-M annotate<anything>".  I could make it
> >        more strict, but I was not sure if it was worth it.
> 
> Will something equivalent then also work from the gdb prompt? (I expect
> so, as I think per-arch option option parsing covers both, but I'd like
> to double check.)
> 

I have added some GDB folks from Intel side to see if they have some opinion
on that.

Thx,
Haochen


More information about the Binutils mailing list