On Thu, Aug 10 2017, Mike Belopuhov <[email protected]> wrote:
> On Thu, Aug 10, 2017 at 12:27 -0400, Martin Pieuchot wrote:
>> On 10/08/17(Thu) 18:21, Mark Kettenis wrote:
>> > > Date: Thu, 10 Aug 2017 12:10:27 -0400
>> > > From: Martin Pieuchot <[email protected]>
>> > >
>> > > Building a profiled binary, using -pg with clang doesn't work as
>> > > expected. A gmon.out is properly generated when the binary exit,
>> > > but it doesn't include any profiling data.
>> >
>> > Seems to work when I pass -nopie on the command line. Did this ever
>> > work since we switched to static PIE?
>>
>> Yes, it works with GCC, I use it all the time.
>>
>
> Not sure about that... Jul 24 snap (from before the clang switch):
I think this is just pledge(2) kicking in.
> kemushi:usr.bin/nc% cc --version
> cc (GCC) 4.2.1 20070719
> Copyright (C) 2007 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> kemushi:usr.bin/nc% make DEBUG="-g -pg"
> cc -O2 -pipe -g -pg -Werror-implicit-function-declaration -MD -MP -c
> /usr/src/usr.bin/nc/netcat.c
> cc -O2 -pipe -g -pg -Werror-implicit-function-declaration -MD -MP -c
> /usr/src/usr.bin/nc/atomicio.c
> cc -O2 -pipe -g -pg -Werror-implicit-function-declaration -MD -MP -c
> /usr/src/usr.bin/nc/socks.c
> cc -g -pg -o nc netcat.o atomicio.o socks.o -ltls -lssl -lcrypto
> netcat.o: In function `main':
> /usr/src/usr.bin/nc/netcat.c:429: warning: warning: mktemp() possibly used
> unsafely; consider using mkstemp()
> kemushi:usr.bin/nc% ./obj/nc
> usage: nc [-46cDdFhklNnrStUuvz] [-C certfile] [-e name] [-H hash] [-I length]
> [-i interval] [-K keyfile] [-M ttl] [-m minttl] [-O length]
> [-o staplefile] [-P proxy_username] [-p source_port] [-R CAfile]
> [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
> [-X proxy_protocol] [-x proxy_address[:port]] [-Z peercertfile]
> [destination] [port]
> zsh: abort (core dumped) ./obj/nc
> kemushi:usr.bin/nc% gdb -c nc.core obj/nc
> GNU gdb 6.3
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "amd64-unknown-openbsd6.1"...
> Core was generated by `nc'.
> Program terminated with signal 6, Aborted.
> Reading symbols from /usr/lib/libtls.so.15.7...done.
> Loaded symbols for /usr/lib/libtls.so.15.7
> Reading symbols from /usr/lib/libssl.so.43.3...done.
> Loaded symbols for /usr/lib/libssl.so.43.3
> Reading symbols from /usr/lib/libcrypto.so.41.2...done.
> Loaded symbols for /usr/lib/libcrypto.so.41.2
> Reading symbols from /usr/libexec/ld.so...done.
> Loaded symbols for /usr/libexec/ld.so
> #0 0x0000000000412d65 in profil () at {standard input}:5
> 5 {standard input}: No such file or directory.
> in {standard input}
> (gdb) where
> #0 0x0000000000412d65 in profil () at {standard input}:5
> #1 0x00007f7ffffee8e0 in ?? ()
> #2 0x000000000042062a in sysctl () at {standard input}:5
> #3 0x0000000000412694 in _mcleanup () at /usr/src/lib/libc/gmon/gmon.c:177
> #4 0x0000000000421d6a in *_libc___cxa_finalize (dso=0x0)
> at /usr/src/lib/libc/stdlib/atexit.c:159
> #5 0x000000000041b997 in *_libc_exit (status=1)
> at /usr/src/lib/libc/stdlib/exit.c:57
> #6 0x000000000040083e in usage (ret=Variable "ret" is not available.
> ) at /usr/src/usr.bin/nc/netcat.c:1751
> #7 0x000000000040395a in main (argc=1, argv=0x7f7fffff3240)
> at /usr/src/usr.bin/nc/netcat.c:385
> Current language: auto; currently asm
> (gdb)
>
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE