RFC: Annotate immediates in x86 disassembly
Jan Beulich
jbeulich@suse.com
Wed Apr 22 10:44:10 GMT 2026
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.
> 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 did try to make this a generic option, rather than specific to the
> x86/x86_64 architecture, but I quickly ran into problems with how
> different ISAs handle the loading of constant values. Still if this
> kind of feature is considered useful it could be added to more
> backends or a per-architecture basis.
Many architectures can only load range restricted constants in a single
insns, so there may not be that many where this is easily possible.
Jan
More information about the Binutils
mailing list