#Best way to view asm of executable
1 messages · Page 1 of 1 (latest)
it might help to use ReleaseSmall to get the size down
although that might also “obfuscate” stuff a bit since itll be more optimized
what exactly are you looking for
honestly I am just curious to see how much my code gets optimised by the compiler
use objdump with -dS flag in the binary. build it in Debug mode.
that’ll show what lines of code correspond to what assembly
or you can use something like https://zig.godbolt.org if your code is pretty small
any way to have this visually in something like vs code?
wdym
i made a gist for this https://gist.github.com/travisstaloch/02820dc30e694a3baa48d2cddaae49a7
haven't used it in while tho
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
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().
well let me know if there are any issues. i'm sure i put it there for a reason.
probably this, the difference is quite a lot
this in combination with -fstrip, and just searching for whatever function i am interested in works for my purposes
thanks guys
zig does a good bit of startup code, none of which will be there if you make your own _start
In CodeLLDB (VS Code plugin) one can see disassembly output
it doesnt hurt but the -fstrip is unnecessary, releasesmall strips by default
ill take a look!
oh lol, makes sense
You need to look up the "LLDB: Toggle Disassembly" command in the Shift+Cmd+P/Shift+Ctrl+P list
how does this work? it doesnt seem to do much
Just use Compiler Explorer
If you just wanna see how code optimizes, Compiler Explorer is the easiest way
It shows you the disassembly of the current code location you are debugging at.
IIUC this works for small code snippets, but whenever you want to inspect real code generated for your project, I'm not sure how to use compiler explorer for that and have been always using the debugger's disassembly (combined with some breakpoints). Am I missing something?
- it's often useful to examine small snippets
- you can run compiler explorer locally to use it with larger projects
- 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 😉
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