简体   繁体   中英

Reverse engineering - compile with debug info

I am learning about reversing a program and I was wondering .. if I compile with debug info :

gcc -g ....

Does this help the reversing process some how? do I give extra information if I do that? I Couldn't find any information about the subject.

It helps by adding line numbers, file names, macro definitions and such to the resulting binary. However, it does not include the full source of the program inside the program itself.

Here's an example of macro definitions being included in the resulting file:

username@localhost /path/to/source/code $ gcc test.c -Wall -Wextra -gdwarf-4 -g3
username@localhost /path/to/source/code $ grep __STDC_VERSION__ a.out 
Binary file a.out matches

Debugging information is more useful for decompiling when compiling with -g3 , as shown in the above example.

So, the answer to your question is: It gives a little bit of extra information that may be useful in decompiling, but not enough to be able to decompile and recompile the program successfully. If possible, just give the source code to the person.

If you want to prevent decompiling your code, just run strip on it like this after building and debugging your program:

strip program-file

-g should not affect code generation, it just adds information only useful to a debugger to the resulting program file.

If you want to prohibit someone from disassembling or decompiling your software, just include that in your license.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM