Do compiled C++ binaries store the original source code? -
when run c++ code, , receive error, manages print out exact line in particular source file on error occurred. great debugging, believe program running built in release mode. questions is, programs built in release mode store original source c++ code, references in compiled binary? seems inefficient way create binary if distributed consumers, rather developers.
i never saw "mainstream" c++ compiler store original source. when see references source, typically boils down 1 of tricks:
- references source file/line: these created via macros. logging libraries provide macro includes in bowels
__file__,__line__macros, which, at compile time, expands current file , line; macros__function__common extension; - expressions in failed asserts:
assertmacro (and similar beasts) not uses__file__,__line__, stringifies (again, @ compile time) given expression, show whenassertfails; - names of classes in executable: if enable rtti, compiler has store somewhere names of types, allow use of
typeidoperator; stuff see in debugger/in stack traces: comes debugging information, allows reverse mapping instruction pointer location in sources , function name; of course requires having debug information (which may or may not generated in release builds, or may put in separate file) , actual sources (if want code is).
since both quite big (in project work on 12x size of stripped executable) , can in reverse engineering, shipped customer (but kept in-house, able analyze "raw" stack traces generated released application).
Comments
Post a Comment