Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect code compiled with LTO?

Tags:

gcc

lto

Exist any way to detect if code is compiled with -flto?

Example is classic library or executable under Linux compiled with GCC (4.9.1), without debugging.

like image 616
okias Avatar asked Oct 12 '14 07:10

okias


People also ask

What is LTO compilation?

Link time optimizations (abbr. LTO) are just that, optimizations done during linking. Linker is aware of all the compilation units and can optimize more compared to what conventional compiler can do. The most important optimizations that linker does are inlining and code locality improvements.

What is LTO programming?

Link Time Optimization (LTO) refers to program optimization during linking. The linker pulls all object files together and combines them into one program. The linker can see the whole of the program, and can therefore do whole-program analysis and optimization.


1 Answers

Considering that LTO information is stored in several ELF sections inside object files (see LTO file sections), you could try and see what readelf returns (as used for instance in this answer).

Look for .gnu.lto_.xxx entries.

like image 173
VonC Avatar answered Oct 02 '22 22:10

VonC