11

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

8
  • Copy the file to a machine that HAS tools to analyze the file? Jul 3, 2013 at 16:24
  • Yes its possible.. let me try it. Jul 3, 2013 at 16:25
  • Thank you @MatsPetersson.. It really helped. Please post it as answer. Jul 3, 2013 at 16:27
  • Also handy is the strings command. Jul 3, 2013 at 17:28
  • @meaning-matters, please explain how strings will be helpful. Its available in the system. Jul 3, 2013 at 17:30

3 Answers 3

12

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

1
  • This is the easiest to do, though OP clearly stated he has no tools like objdump.
    – Tomer W
    Mar 1, 2023 at 9:15
2

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.

1
  • Additionally, there are many strings for Errors and Logging entries which are not symbols... this is highly unlikely.
    – Tomer W
    Jun 1, 2016 at 10:31
2

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.