From sacadmin Fri Oct 26 17:30:32 2007
Received: from sac.sfbay.sun.com (localhost [127.0.0.1])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l9R0UWM9028512;
	Fri, 26 Oct 2007 17:30:32 -0700 (PDT)
Received: (from ab196087@localhost)
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8/Submit) id l9R0UWGm028508;
	Fri, 26 Oct 2007 17:30:32 -0700 (PDT)
Date: Fri, 26 Oct 2007 17:30:32 -0700 (PDT)
From: Ali Bahrami <ab196087@sac.sfbay.sun.com>
Message-Id: <200710270030.l9R0UWGm028508@sac.sfbay.sun.com>
To: PSARC-record@sac.sfbay.sun.com
Subject: elfdump -T, and simplified matching [PSARC/2007/620 Self Review]
Status: RO
Content-Length: 570


Template Version: @(#)sac_nextcase 1.64 07/13/07 SMI
This information is Copyright 2007 Sun Microsystems
1. Introduction
    1.1. Project/Component Working Name:
	 elfdump -T, and simplified matching
    1.2. Name of Document Author/Supplier:
	 Author:  Ali Bahrami
    1.3  Date of This Document:
	26 October, 2007
4. Technical Description
    See the case directory for more detail

6. Resources and Schedule
    6.4. Steering Committee requested information
   	6.4.1. Consolidation C-team Name:
		ON
    6.5. ARC review type: Automatic
    6.6. ARC Exposure: open


From Ali.Bahrami@Sun.COM Fri Oct 26 17:36:25 2007
Received: from sunmail5.uk.sun.com (sunmail5.UK.Sun.COM [129.156.85.165])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l9R0aOki028555
	for <psarc-ext@sac.sfbay.sun.com>; Fri, 26 Oct 2007 17:36:25 -0700 (PDT)
Received: from nwk-avmta-2.sfbay.sun.com (nwk-avmta-2.SFBay.Sun.COM [129.145.155.6])
	by sunmail5.uk.sun.com (8.13.8+Sun/8.13.7/ENSMAIL,v2.2) with ESMTP id l9R0WqrE028975
	for <@sunmail2sca.sfbay.sun.com:psarc-ext@sun.com>; Sat, 27 Oct 2007 01:32:53 +0100 (BST)
Received: from pmxchannel-daemon.nwk-avmta-2.sfbay.sun.com by
 nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0JQJ00205O6S4L00@nwk-avmta-2.sfbay.sun.com> for psarc-ext@sun.com
 (ORCPT psarc-ext@sun.com); Fri, 26 Oct 2007 17:32:52 -0700 (PDT)
Received: from brmea-mail-2.sun.com ([192.18.98.43])
 by nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0JQJ00MNVO6LOA10@nwk-avmta-2.sfbay.sun.com> for
 psarc-ext@sun.com (ORCPT psarc-ext@sun.com); Fri,
 26 Oct 2007 17:32:45 -0700 (PDT)
Received: from fe-amer-10.sun.com ([192.18.109.80])
	by brmea-mail-2.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l9R0Wjnh021141	for
 <psarc-ext@sun.com>; Sat, 27 Oct 2007 00:32:45 +0000 (GMT)
Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007))
 id <0JQJ00I01O6IST00@mail-amer.sun.com>
 (original mail from Ali.Bahrami@Sun.COM)
 for psarc-ext@sun.com (ORCPT psarc-ext@sun.com); Fri,
 26 Oct 2007 18:32:45 -0600 (MDT)
Received: from [172.20.25.67] by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007))
 with ESMTPSA id <0JQJ00D1GO6KIZ20@mail-amer.sun.com> for psarc-ext@sun.com
 (ORCPT psarc-ext@sun.com); Fri, 26 Oct 2007 18:32:45 -0600 (MDT)
Date: Fri, 26 Oct 2007 18:32:44 -0600
From: Ali Bahrami <Ali.Bahrami@Sun.COM>
Subject: PSARC/2007/620 elfdump -T, and simplified matching
Sender: Ali.Bahrami@Sun.COM
To: psarc-ext@Sun.COM
Message-id: <4722872C.5000002@Sun.COM>
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.2.0.264296
User-Agent: Thunderbird 2.0.0.6 (X11/20070802)
Status: RO
Content-Length: 5584

I am sponsoring the following self-reviewed case for myself.

I belive it qualifies for self review: The changes have limited
scope, are similar to existing features, and preserve backward
compatibility. I will promote it to a fastrack if an objection
is raised.

Release Binding:			Patch/Micro
-T elfdump option:			Committed
Behavior of (-I, -N, -T) when used
   without another selection option:	Committed

---------------------------------------------------------------------------

This case extends the command interface to the elfdump utility in
two ways:

	1) Adds the -T option, to allow for the selection of section
	   and program headers by type. elfdump already has the -I
	   option for selecting by index, and -N for selecting by name.
	   -T will be accepted in any context where -I and -N are allowed.
	   These three options (-I, -N, and -T) will be collectively
	   referred to as the "match options".

	2) In the case where a match option (-I, -N, -T) is used,
	   and no other option specifying the information to be
	   displayed is provided, elfdump will examine the object
	   for matching sections, and will display them.

The combination of these changes is expected to yield the following
benefits:

	- Simplifies elfdump use in the common case where
	  the user wants to display a single section.

	- Makes it possible to add support in elfdump for displaying
	  new section types without necessarily requiring the addition
	  of a new command line option to select it.

	- Completeness / Convenience

I have placed an updated elfdump(1) manpage, documenting these
features, in the case materials directory.


Simplification
--------------

    Consider the common case where the user wishes to display the
contents of the dynamic symbol table without showing any other
symbol tables. Prior to this change, the syntax for that would be:

	% elfdump -s -N .dynsym file

This is redundant. The user is required to specify that
symbol tables are being dumped, something that elfdump
can easily determine given the name. Furthermore, elfdump
has to independently determine this anyway, so no work is saved.
After this change, it suffices to simply say

	% elfdump -N .dynsym file

It should be noted that the '-s' option is still useful in the case
where the user wants to dump all symbol tables. Also, this change
only takes effect in a case that was previously a usage error, so
backward compatibility is preserved.

Slowing Down Command Line Option Growth
---------------------------------------

    Prior to this change, every time we added the ability to display
a new section type, we also added a new command line option for
selecting it. In the early days, this made intuitive sense, and
the option letters were reasonable (-s for symbol tables, etc).
However, as elfdump has grown, we have ended up with a large number
of options, some of which have little or no mnemonic value
(e.g. -y for SHT_SUNW_syminfo). Furthermore, some of these options
are rarely used, and provide little incremental value to elfdump.

The change proposed by this case makes it possible to add support
for new sections without adding an elfdump command line option, while
allowing the user to specify that only those sections should be
displayed. For example, we have an outstanding request to add
dumping of ELF signature sections to elfdump:

	6608612 elfdump should display .SUNW_signature section

We are not planning to add a command line option for this.
Instead, the user will be able to display signature sections
using one of the following:

	% elfdump -N .SUNW_signature file
	% elfdump -T SHT_SUNW_SIGNATURE file

The -T option does case insensitive matching, and allows the omission
of the SHT_ prefix, so the second version might also be written as

	% elfdump -T sunw_signature file


Convenience / Completeness
--------------------------
Given the ability to match by index and by name, the ability
to match by type is an obvious missing feature. These are the
three ways in which sections and program headers are commonly
specified. They are equivalent ways of specifying the same thing,
but one of them will often be notably more convenient for the user
than the others, depending on the particular query being made.

It is usually true that well known section types have "standard"
names. For instance, sections of type SHT_DYNSYM are usually named
".dynsym". However, this name is simply a convention, and not a
formal requirement. The -T option allows the caller to specify the
desired section more precisely.

Beyond that, the ability to match based on type can be useful
in the situation where sections of different type have the same
name. An example of this occurs with our versioning sections.
Solaris ELF objects give both version definition and version
needed sections the same name (.SUNW_version):

	% elfdump -c -N .SUNW_version /bin/elfedit

	Section Header[8]:  sh_name: .SUNW_version
	    sh_addr:      0x80532cc       sh_flags:   [ SHF_ALLOC ]
	    sh_size:      0x90            sh_type:    [ SHT_SUNW_verneed ]
	    sh_offset:    0x32cc          sh_entsize: 0x1 (144 entries)
	    sh_link:      7               sh_info:    4
	    sh_addralign: 0x4

	Section Header[9]:  sh_name: .SUNW_version
	    sh_addr:      0x805335c       sh_flags:   [ SHF_ALLOC ]
	    sh_size:      0x1c            sh_type:    [ SHT_SUNW_verdef ]
	    sh_offset:    0x335c          sh_entsize: 0x1 (28 entries)
	    sh_link:      7               sh_info:    1
	    sh_addralign: 0x4

The -T option allows either one of these sections to be matched
unambiguously.




