RFC: Annotate immediates in x86 disassembly

Nick Clifton nickc@redhat.com
Tue May 12 09:10:34 GMT 2026


Hi Jan,

>> Good guess. First and foremost I can't help the impression that is this
>> tailored to objdump, but won't interact very well with gdb.

Err, does GDB use the disassembler output somehow ?  I mean other than for
displaying lines of disassembly ?  My point is that this change is just
about unifying the framework used to record and display comments alongside
lines of disassembled output.  How would that affect GDB ?


> While doing this, I came to wonder: Is it really a good idea to include
> this for shared libraries? They're commonly linked to address 0, and
> hence relatively low numbers will (often bogusly) resolve to addresses.
> Shared libraries ought to have (base) relocations for anything that's
> an address, so there ought to be better ways to report the symbolic
> targets. Same for PIE, really.

Fair enough.  It would be simple to add a test for the start address of
the binary being set to 0 and disabling the annotation in this case.

> Further, quite a few insns have immediates which surely aren't addresses.
> 8- and often 16-bit ones, or the 32-bit ones used by the recently added
> MSR-IMM and USER-MSR insns. Imo we'd better avoid the address lookup in
> such cases.

I guess that there is a balancing act here.   The heuristic already skips
any immediates that are less than the starting address of the binary.  It
could probably be extended to skip immediates that are larger than the
end address of the binary as well.  Other than that though I am not sure
how we could make a better determination that an immediate value might
correspond to a symbolic value.

One of the reasons that I made this feature only enabled via a command
line option was the fear that the cost of the symbol lookups would
significantly slow down the speed of the disassembly.  With the command
line option, I figure that if users want the feature then they are
prepared to pay the speed cost.

Cheers
   Nick




More information about the Binutils mailing list