1
int goo(int g)
{
    int filedesc = open("testfile.txt", O_WRONLY | O_APPEND);
}

int foo(int f)
{
    goo(2);
}

int main()
{
    foo(1);
}

gcc no_symbol.c -o no_symbol

In GDB

(gdb) r
Starting program: /home/samuel/project/no_symbol 

Breakpoint 1, 0x000055555555463e in goo ()
(gdb) bt full
#0  0x000055555555463e in goo ()
No symbol table info available.
#1  0x0000555555554676 in foo ()
No symbol table info available.
#2  0x0000555555554687 in main ()
No symbol table info available.

Is there any method I can know g and f's values without the source code?

Samuel
  • 803
  • 8
  • 17
  • Do you need that `using namespace` thingy in C like you do in C++? I assume `testfile.txt` is in the same directory as your main file, right? – Adrian Keister Oct 08 '20 at 02:22
  • testfile.txt in the same directory – Samuel Oct 08 '20 at 02:23
  • Try `info args` to print the arguments to a stack frame. – Barmar Oct 08 '20 at 02:48
  • No symbol table info available. – Samuel Oct 08 '20 at 02:56
  • 1
    You will have to resort to assembly level debugging. Dump the assembly to a file using `objdump`, then rely on `gdb` support for assembly instruction stepping. Of course, there exist much more advanced tools for that exact purpose, such as Hex Rays Ida. – oakad Oct 08 '20 at 06:52
  • @oakad You are right. But I have a question. Is there are any method add standard function (read, write and so on) debug symbol to the no debug symbol program? – Samuel Oct 09 '20 at 06:53
  • Gdb can use external debug information - see here, for example: https://stackoverflow.com/questions/866721/how-to-generate-gcc-debug-symbol-outside-the-build-target . However, if you don't have any access to the original objects used to build your executable, you're facing an advanced decompilation/reverse engineering problem, and there is no magic solution for those (yet, almost any program can be reverse engineered with some determination :-). – oakad Oct 09 '20 at 07:48
  • Even for standard functions only, you need a tool that can do "function fingerprinting". Hex Rays Ida Pro is quite handy in this regard. – oakad Oct 09 '20 at 07:50

0 Answers0