4

i have a shared obj file say a.so and in that i want to see if a particular function (say fname) is inlined or not. I tried following 4 ways and getting different answers :

1) nm a.so | grep fname  

-> this doesn't give any o/p implying that the function is inlined. Please let me know if this is sufficient check to see if a function is inlined or not.

2) objdump -d a.so | grep fname  

->this doesn't give any o/p implying that the function is inlined. Please correct me if i am wrong in conclusion here.

3) objdump -W a.so  

-> for function fname, this gives me the following o/p the last line of which says "declared as inline but ignored"

 DW_AT_name        : (indirect string, offset: 0x10411): fname
 DW_AT_decl_file   : 246
 DW_AT_decl_line   : 40
 DW_AT_prototyped  : 1
 DW_AT_inline      : 2      (declared as inline but ignored)

4) pfunct -G a.so | grep fname
->this dwarves utility shows the function fname implying that the function is not inlined.

Now first two ways imply that the function is inlined while rest two say the opposite. Can anyone please explain the following :

1) Why are there differences in the above 4 ways ? 
2) Are there any known issues with objdump and pfunct ? 
3) Also let me know the best way to check if a function is inlined or not.

Any help will be greatly appreciated. Thanks !!!

mezda
  • 3,537
  • 6
  • 30
  • 37
  • 4
    A function may be inlined in some places and not inlined in other ones. Is your function called at all in the .so? – Wojtek Surowka Aug 27 '14 at 12:18
  • yes, the function is static and called at only one place in that .c file – mezda Aug 27 '14 at 12:27
  • Was this shared obj file compiled with debug information? If not then a succesfully inlined function will have no evidence left around to say that it was ever a function at all. – Andy Brown Aug 27 '14 at 12:38
  • yes .so is compiled with debug information – mezda Aug 27 '14 at 12:48
  • `Also let me know the best way to check if a function is inlined or not.` --- what if inspect code under `gdb`? You can create a test program and run it under `gdb`. –  Aug 27 '14 at 13:08
  • objdump -d is the best way to check if you have separated function definition. Some of you check actually read the dwarf debug information that includes also information for inlined functions. If language is C++ you have to remember that compiler mangles function names. Then -C parameter can help. – Pauli Nieminen Aug 27 '14 at 13:17

1 Answers1

3

Since the function is called at only one place in the .c file, the best way to check if the function is inlined is the following:

objdump -d a.so | grep call | grep fname

If there is any result, then fname is not inlined. Otherwise, it must be inlined because it is called at only one place and the call site in not found.

writalnaie
  • 180
  • 10
  • any explanation for why the difference in results using 4 approaches as above ? – mezda Aug 29 '14 at 10:38
  • The 4 approaches: 1) Output `fname`'s address when exists. 2) Output where `fname` is used in the code. It includes 1) and where `fname` is called. 3) Output the debugging information such as the defining line and file, its signature, etc. 4) I'm sorry I don't know about `pfunct`. – writalnaie Aug 30 '14 at 00:32
  • It seems that these days, `arm-none-eabi-objdump -d` does not write `call` in its output, so `grep call` in the above command will not really return anything; just `grep fname` seems to work ... – sdbbs Oct 27 '22 at 11:46