RFC: AArch64 Disassembler: Annotate undefined instructions

Richard Earnshaw Richard.Earnshaw@arm.com
Tue Apr 28 12:13:17 GMT 2026


On 28/04/2026 12:54, Richard Earnshaw (foss) wrote:
> [Apologies if you get two copies of this reply; I thought I sent one earlier, but I can't see it anywhere in my mail system, so perhaps I just managed to delete it without sending.]
> 
> On 27/04/2026 16:45, Nick Clifton wrote:
>> Hi Guys,
>>
>>   Attached is proposed patch to enhance the AArch64 disassembler with a
>>   "-M annotate" command line option.  When enabled the option tell the
>>   disassembler that undefined instructions might actually be the
>>   addresses of objects and that it should look them up in the symbol
>>   table.
>>
>>   So for example without the option being enabled, disassembling
>>   non-code sections might produce results like this:
>>
>>     000000000041fdd8 <__frame_dummy_init_array_entry>:
>>       41fdd8:	00400764 	.inst	0x00400764 ; undefined
>>       41fddc:	00000000 	udf	#0
>>
>>   Whereas with the option enabled this changes to:
>>   
>>     000000000041fdd8 <__frame_dummy_init_array_entry>:
>>       41fdd8:	00400764 	.inst	0x00400764 ; [frame_dummy]
>>       41fddc:	00000000 	udf	#0
>>
>>   There are limitations to the patch.  If a piece of data just happens
>>   to decode to a valid instruction, then the annotation will not take
>>   place.  Plus the patch assumes that there is no point in annotating
>>   static object files as their symbols will not have been resolved.
>>   (Plus you can always disassembler with relocation display enabled to
>>   see where symbols are being referenced).
>>
> 
> This is what mapping symbols are supposed to address.  If the user writes '.word' in a code section then the value will be tagged with $d and the output should then disassemble as data.  '.inst' means 'this is an instruction'.
> 
> R.
> 
>>   Comments, thoughts, suggestions ?
>>
>> Cheers
>>   Nick
>>
> 

For example:

        .text
        .inst 0x12345678
        .word 0x12345678

gives:

 objdump -d test.o

test.o:     file format elf64-littleaarch64


Disassembly of section .text:

0000000000000000 <.text>:
   0:   12345678        and     w24, w19, #0xfffff003
   4:   12345678        .word   0x12345678

Maybe .word should be annotated with a suitable label, but I don't think .inst should.

R.


More information about the Binutils mailing list