1

In my program I neither include math.h nor do I link -lm against it: g++ -std=c++11 -g -O0..

Still ldd shows this

ldd ./bin/apps/dummy
linux-vdso.so.1 =>  (0x00007fff9e5fe000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1fb38cf000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1fb36b8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1fb32f1000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1fb2feb000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1fb3c10000)

Does gcc automatically call math functions? If yes how can I find out which those functions are and wherefrom they are called?

hlitz
  • 635
  • 6
  • 24
  • It does so for c++ as it is required by the runtime, see this answer here: http://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c – eckes Feb 15 '15 at 22:28
  • How can I find out which functions in math get called and why? Perf shows me some large overheads going on in libm and I need to know why. Also if I use a minimal example and compile it as above, libm does not get linked so I assume gcc has a good reason when to include it. – hlitz Feb 15 '15 at 22:51
  • ltrace can list the methods called and nm/objdump -T should list the symbols imported. (But I think if you already use perf it might be best to make it stack aware so you can see the method level). – eckes Feb 15 '15 at 23:05

0 Answers0