Hi stupid question, anyone a good idea how I can find the END of a function(procedure) in a Nim binary file ? Function start is easy via symbols. Compiler flags are "-d:release", "--opt:size", I can change the compiler flags (as long as it doesn't change the produced binary code), but I can't add any source code.
Nim binaries aren't inherently different to any other binaries that are compiled from other native languages, especially considering that Nim compiles to C which is then compiled by the C compiler. So you don't need any techniques that are exclusive to Nim here.
yeah, that's clear, using a good disasm would work (and actually this is my workarounf itm), but I am talking about automation. I am reading in several Nim std lib files and compile them. This produces several executables which I parse the symbols from which include the functions and their start address. Finding the end of a function is extremly tricky and Disasms like IDA or Radare etc using a ton of logic to find that out (and even they are sometimes wrong). I was hoping Nim might store some info somewhere at compile time or there might be an option to do so (I remember there was a gcc switch which helps with that but don't remember the details). In some cases there is some info in binaries in the RUNTIME_FUNCTION record in the .pdata section, but that is tricky with relocations etc.... So long story short, if you don't know any way, I guess there is no easy way and I have to script a disasm to find this out, which is a bit ugly... anyway thx.
I have done this in github.com/treeform/hottie. I used objdump to disassemble the binary, then parsed the objdump dwarf text format. The text format contains information about where functions start and end, as well as whether they get broken up into multiple chunks or have multiple 'ret' instructions inside.