内联目标文件中的函数 [英] Inlining functions from object files
问题描述
我要内联的一些功能,而我没有code。他们在目标文件present。有没有办法用gcc做呢?
I want to inline some functions of which I don't have the code. They are present in an object file. Is there a way to do it with gcc?
在换句话说,我希望在联我自己的code文件,包含这些函数的目标文件来执行这些功能的内联。
In other words, I want to perform inlining of those functions while linking my own code files with the object file that contain those functions.
推荐答案
4.5版本开始,GCC支持-flto开关使链接时优化(LTO)。 LTO可以从单独的对象文件内联函数。
Starting with version 4.5, GCC supports the -flto switch which enables Link Time Optimization (LTO). LTO can inline functions from separate object files.
有一个陷阱,但。由于的 -flto
的工作方式,它会只使用对象文件中使用开关编译的。据我了解,GCC通过将源$ C $ C的中间形式到目标文件实现LTO - 如果这中间code是不是对象文件,该对象文件中的code赢了'T是'内联'。
There's a catch though. Because of the way that -flto
works, it'll only be of use for object files that were compiled using that switch. As I understand it, GCC implements LTO by placing a intermediate form of the source code into the object file - if that intermediate code isn't in the object file, the code in that object file won't be 'inlined'.
请参阅Can链接器内联函数?的一些其他细节。
See Can the linker inline functions? for some additional details.
这篇关于内联目标文件中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!