Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out compilation optimization flag from executable

Here I have an executable without knowing its build environment, with the assumption of gcc/g++ being used. Is there a way to find out the optimization flag used during compilation (like O0, O2, ...)?

All means are welcomed, no matter it's by analyzing the binary or some debug test via gdb (if we assume that -g flag is available during compilation).

like image 978
John Avatar asked Feb 16 '12 08:02

John


Video Answer


1 Answers

If you are lucky, the command-line is present in the executable file itself, depending on the operating system and file format used. If it is an Elf-file, try to dump the content using the objdump from GNU binutils

like image 176
Lindydancer Avatar answered Nov 11 '22 22:11

Lindydancer