Bug 193110

Summary: [dtrace] dtrace testcases don't call elfdump properly
Product: Base System Reporter: Enji Cooper <ngie>
Component: binAssignee: Mark Johnston <markj>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, markj
Priority: --- Flags: bugmeister: mfc-stable10?
bugmeister: mfc-stable9?
bugmeister: mfc-stable8?
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Enji Cooper freebsd_committer freebsd_triage 2014-08-28 23:32:31 UTC
elfdump on FreeBSD requires arguments in order to dump sections for binaries compiled with CTF sections.

$ elfdump ./hello_world
usage: elfdump -a | -cdeGhinprs [-w file] file
$ elfdump -a ./hello_world | grep SUN
        sh_type: SHT_SUNW(GNU)_versym
        sh_type: SHT_SUNW(GNU)_verneed
        sh_name: .SUNW_ctf

The testcases assume that no arguments are required, which cause the testcases to fail:

$ grep --include \*.ksh
./failure.47/tst.aouttype.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.48/tst.chasestrings.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.49/tst.libtype.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.51/tst.pidprint.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.52/tst.pidprinttarg.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.53/tst.printtype.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.54/tst.printtypetarg.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.55/tst.userlandkey.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.56/tst.userstrings.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'
./failure.66/tst.aouttype.ksh:elfdump "./$exe" | grep -q '.SUNW_ctf'

Either elfdump needs to default to -a, or the testcases need to be changed to pass in the appropriate options to dump the section with ".SUNW_ctf" (apparently it seems to be "-c"):

$ elfdump -c ./hello_world | grep SUN
        sh_type: SHT_SUNW(GNU)_versym
        sh_type: SHT_SUNW(GNU)_verneed
        sh_name: .SUNW_ctf
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2014-08-28 23:36:28 UTC
Neither option is portable according to the elfdump manpage I just found: http://illumos.org/man/1/elfdump . The easiest way to deal with this is that elfdump should be changed to assume '-a'.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2014-08-29 18:19:59 UTC
Note that these are userland CTF tests. Support for this feature was merged in r267941, but it's not yet functional; it requires some as yet unimplemented support in libproc. See r267940.
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2014-08-29 20:30:27 UTC
(In reply to Mark Johnston from comment #2)
> Note that these are userland CTF tests. Support for this feature was merged
> in r267941, but it's not yet functional; it requires some as yet
> unimplemented support in libproc. See r267940.

Gotcha :) -- I'll add those to the list of "filtered tests" on the branch.
Comment 4 commit-hook freebsd_committer freebsd_triage 2014-09-16 22:54:56 UTC
A commit references this bug:

Author: markj
Date: Tue Sep 16 22:54:18 UTC 2014
New revision: 271693
URL: http://svnweb.freebsd.org/changeset/base/271693

Log:
  Fix elfdump(1) usage in the userland CTF tests.

  PR:		193110
  MFC after:	1 week
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2014-09-16 22:57:22 UTC
Fixed by using elfdump(1) in a way that should work in illumos as well. This usage is also more correct, since we're specifically looking for a section called .SUNW_ctf.
Comment 6 Glen Barber freebsd_committer freebsd_triage 2015-07-08 18:02:29 UTC
Close PRs that have had a corresponding fix committed.