disassemblers (was Re: [PATCH 1/2] x86: Remove dynamic NOP selection)

From: Thorsten Glaser
Date: Sat Jan 20 2024 - 13:23:00 EST


Dixi quod…

>>Is there some sane tool that just does the sane thing and shows this as
>
>The only other disassemblers I know don’t know about ELF objects
>at all, I’m sorry to say.

I have searched through my bookmarks and found “Agner Fog’s objconv”
https://www.agner.org/optimize/#objconv which I had not yet tried as
it comes with a .exe but apparently, the included GPL source builds
on GNU/Linux (and BSD and MacOSX) as well.

Usage is: ./objconv -fgasm filename.o

This will write filename.asm ⚠ into the same directory as the .o file,
surprisingly.

It works for i386 and amd64 but not x32 (aka amd64ilp32) which is
mis-disassembled as if it were i386. Sample output fragment:

tsv_header:
sub rsp, 8 # 00E3 _ 48: 83. EC, 08
lea rdi, [.LC7+rip] # 00E7 _ 48: 8D. 3D, 00000000(rel)
call puts@PLT # 00EE _ E8, 00000000(PLT r)
add rsp, 8 # 00F3 _ 48: 83. C4, 08
ret # 00F7 _ C3

Bit irritating is it uses decimal numbers…

sub rsp, 232 # 0102 _ 48: 81. EC, 000000E8

… and the way the input is separated with colon, period and comma,
but it’s legible enough.

Credits to Peter Cordes for the discovery.

bye,
//mirabilos
--
When he found out that the m68k port was in a pretty bad shape, he did
not, like many before him, shrug and move on; instead, he took it upon
himself to start compiling things, just so he could compile his shell.
How's that for dedication. -- Wouter, about my Debian/m68k revival