#Best way to view asm of executable

1 messages · Page 1 of 1 (latest)

dusty cedar
#

Was just wondering how to properly inspect the assembly of my executable, since with femit-asm=main.s I get quite a large file, I don't quite know where to look

wary forum
#

although that might also “obfuscate” stuff a bit since itll be more optimized

#

what exactly are you looking for

dusty cedar
#

honestly I am just curious to see how much my code gets optimised by the compiler

hot trail
#

use objdump with -dS flag in the binary. build it in Debug mode.

that’ll show what lines of code correspond to what assembly

dusty cedar
hot trail
#

wdym

steel urchin
#

haven't used it in while tho

hot trail
#

there isn't really a need for your own _start function

#

objdump adds headers to functions that indicate their name and origin, so you can just search by that

steel urchin
#

i think i added that to reduce the asm size. not sure

#

(the _start() fn)

#

no i think thats necessary for some reason. pretty sure you can't do much of anything in _start().

hot trail
#

_start is the same as any function

#

it's just noreturn and takes no arguments

steel urchin
#

well let me know if there are any issues. i'm sure i put it there for a reason.

regal sable
dusty cedar
#

thanks guys

regal sable
#

zig does a good bit of startup code, none of which will be there if you make your own _start

modest grail
regal sable
dusty cedar
modest grail
dusty cedar
pearl swallow
#

Just use Compiler Explorer

#

If you just wanna see how code optimizes, Compiler Explorer is the easiest way

modest grail
modest grail
pearl swallow
#
  1. it's often useful to examine small snippets
  2. you can run compiler explorer locally to use it with larger projects
modest grail
#
  1. you can run compiler explorer locally to use it with larger projects
    You mean like offline? I was not aware of this option, nice. Still the debugger's disassembler does everything I need ATM 😉
pearl swallow
#

Yep

#

It's open source, you can just download it and host it yourself

#

And in that mode it'll read files from your local drive if you want

#

And yeah, debugger works fine if you know what you're doing

#

It's a bit more confusing for someone who's not used to debuggers

#

And again, compiler explorer is super nice for testing small snippets