How to find out which functions were NOT inlined

雨燕双飞 提交于 2019-12-21 09:35:14

问题


Is there a way to obtain a list of functions that were NOT inlined anywhere? Either by passing an option to gcc or by inspecting the binary?

EDIT: I know how to explicitly ask for a function not to be inlined by using gcc's builtin attribute noinline.


回答1:


Use gcc's -fdump-tree-all and search the dump files for "inline".




回答2:


Add -fdump-ipa-inline to your compiler options.

Grep the file yoursourcefile.inline which is created next to the object file for "Considering inline candidate" to find out all functions that the compiler considered inlining.

Grep the file for "Inlined into" to find out all functions that the compiler finally did inline.
Grep for "inline_failed:" if you are interested for the reason why the compiler turned down a candidate (e.g. "call is unlikely and code size would grow").




回答3:


You can use nm command in Unix/Linux to get list of symbols in a binary.
If the function is not inlined its symbol name will be present in the binary.




回答4:


'inline' is NOT an attribute of a function, a function can be both inlined and non-inlined. when you call a function, the compiler decide whether inline it or not, if there are multiple calls, the compiler may choose different option for different call. if there is at least one non-inlined call, the function will be appear in the symbol table. and if it is exported it will also appear in the symbol table.

so there is no way to check a function is inlined or not, you can only check a specific call is inlined or not by reverse engineer.



来源:https://stackoverflow.com/questions/9190359/how-to-find-out-which-functions-were-not-inlined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!