Reputation: 3097
I need to know whether a binary has debugging symbols in it or not. Its a production system and so doesnt have commands like file
or objdump
or gdb
.
Can provide more info when needed.
OS: Debian
Upvotes: 12
Views: 12367
Reputation: 3443
Best of all, Take some tools with you!
if you cant, then you should know the format of the Binary,
on Linux Systems, it is ELF...
you can check to find sections such as .symtab
or .debug_
.
if they exists, you have all the symbols in your binaries.
another idea, is to plant some symbol (e.g. my_check_symbol_to_see
)
then grep this symbol...
Upvotes: 2
Reputation: 3767
probably you are looking for a tool like objdump
Lets say we have a small program like this
#include <stdio.h>
int main()
{
printf("Hello ");
return 0;
}
compile normally now
gcc example.c -o example
now lets check presence of debugging symbols using objdump tool
objdump -h example | grep debug
we won't find any of course
now lets try again by compiling with debug options
gcc -g example.c -o example
objdump -h example | grep debug
26 .debug_aranges 00000030 0000000000000000 0000000000000000 000008b0 2**0
27 .debug_pubnames 0000001b 0000000000000000 0000000000000000 000008e0 2**0
28 .debug_info 0000008b 0000000000000000 0000000000000000 000008fb 2**0
29 .debug_abbrev 0000003f 0000000000000000 0000000000000000 00000986 2**0
30 .debug_line 0000003f 0000000000000000 0000000000000000 000009c5 2**0
31 .debug_str 00000087 0000000000000000 0000000000000000 00000a04 2**0
32 .debug_pubtypes 00000012 0000000000000000 0000000000000000 00000a8b 2**0
man -a objdump might help a lot more
Upvotes: 12
Reputation: 129374
The easy solution, if you don't know if the binary has symbols or not and there are no tools on the actual machine you have the binary on, is to use something like scp
(secure remote copy) to copy the file to a machine that has tools.
As the other comment says, using the strings
command, which prints anything it finds that "looks like a string" (a long enough sequence of "printable" characters), but it's not quite as reliable, as you never really know what the debug symbols look like, and you can get false positives from code containing symbols from macros etc.
Upvotes: 2