I confirm that bug. If it happens that the program uses anything beyond libc, -pg does not work and causes a program to segfault. It is certainly not what expected. For example, in modern linux distros, profiling works just fine with shared libraries attached to the program.
On Tue, 2 Mar 2021 at 15:56, Silas <silas_nbli...@nocafe.net> wrote: > On Mon, Mar 01, 2021 at 10:42:56AM +1100, MJ wrote: > > > >On 1/03/2021 10:35 am, RVP wrote: > >>On FreeBSD-12.2 and OpenBSD-6.8 (both having Clang 10.0.1 as the native > >>compiler), the program segfaults even when not linked with any external > >>shared libs. > >> > >>It looks like profiling on the *BSDs needs static binaries (the > >>profile libraries, /usr/lib/*_p.a, are all static anyway). > >> > >>-RVP > >> > > > >That's correct and as expected. Gprof does not profile shared libraries. > > > > I expected it to not produce the call graph for the shared libraries, but > segfaulting is rather strange, no? I didn't find others reporting this, > so I > started to think there is a problem with my environment, although I'm not > using > LD* environment variable or anything related. Should I file a PR? > > Curious fact: I can profile (generate binary, run the program and use > gprof) the > same program normally in NetBSD 8.0 armv7hf (Raspberry Pi 2). >