I compiled the binary with option -gdwarf-3. Then I use the llvm-dwarfdump with option -debug-info to help me to dump the dwarf debugging information. The DW_AT_subprogram could tell me the function boundaries of the target function.
However, I found the dwarf info may miss a lot of functions. I query the symbol table and it returns about 600 functions. However, the dwarf info only provide me about 100 functions. A large part of the code is not listed inside the dwarf info. Is this a normal behavior? I compiled the binary without -static option.
Besides, I would like to get the function boundary and the signatures. However, symbol table would just give me the start address. How can I know the end address and the function signature? Many Thanks
It sounds like you are examining the final executable file. Even without –static it is possible that some libraries are available only statically, and those functions probably will not have debug information. If that is the case, then yes what you are seeing is normal behavior.
If you examine the individual .o files that you compiled, and find functions missing from the debug information, that would be less expected. There are only a couple of reasons to omit a function from the debug information. One is if the source has the “nodebug” attribute, then we will not emit it. I think also in some cases we might not emit debug information for artificial functions, such as compiler-generated constructors, or functions to perform static initialization prior to running main(). The latter two cases would apply only to C++; if you are compiling C code, you don’t need to worry about those.
Hope this helps,