RFC: Annotate immediates in x86 disassembly
Jan Beulich
jbeulich@suse.com
Tue May 12 10:57:31 GMT 2026
On 12.05.2026 11:10, Nick Clifton wrote:
>>> 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 ?
It's used for display only there as I understand, yet that leaves my
comment still relevant. The custom type you use to "override" stream is
objdump-specific, aiui. (Of course that's only a latent problem if, as
you indicated earlier, the feature presently can't be enabled from gdb.
I'm not quite sure this is correct, though.)
>> 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.
Insn operands may want to indicate whether they may express addresses.
Plus as indicated mere (immediate) operand sizes may already provide a
hint.
Jan
More information about the Binutils
mailing list