From owner-psarc Tue May  1 10:57:18 2007
Return-Path: <owner-psarc>
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l41HvIJk016479
	for <psarc@sac.sfbay.sun.com>; Tue, 1 May 2007 10:57:18 -0700 (PDT)
Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l41HuMMa012795
	for <psarc@sac.sfbay.sun.com>; Tue, 1 May 2007 10:56:23 -0700 (PDT)
Received: from fe-amer-09.sun.com ([192.18.108.183])
	by brmea-mail-3.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l41HuMPE026430
	for <psarc@sac.sfbay.sun.com>; Tue, 1 May 2007 17:56:22 GMT
Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 id <0JHD00K01HJWKN00@mail-amer.sun.com>
 (original mail from Ali.Bahrami@Sun.COM) for psarc@sac.sfbay.sun.com; Tue,
 01 May 2007 11:56:22 -0600 (MDT)
Received: from [172.20.25.67] by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 with ESMTPSA id <0JHD00K1VJ5RRMI0@mail-amer.sun.com> for
 psarc@sac.sfbay.sun.com; Tue, 01 May 2007 11:56:16 -0600 (MDT)
Date: Tue, 01 May 2007 11:53:42 -0600
From: Ali Bahrami <Ali.Bahrami@Sun.COM>
Subject: PSARC/2007/247 Add -I option to elfdump
Sender: Ali.Bahrami@Sun.COM
To: psarc@sac.sfbay.sun.com
Message-id: <46377EA6.6010500@Sun.COM>
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
User-Agent: Thunderbird 1.5.0.10 (X11/20070303)

I am sponsoring the following self-reviewed case for
myself - timeout 05/03/2007.
---------------------------------------------------------------------------

I propose a new command line option, -I, to elfdump(1) in order to
allow for the selection of section and program headers by index.
elfdump already has the -N option for selecting by name. -I will
be accepted in any context where -N is allowed.

This change will be integrated with

	6246083 elfdump should allow section index specification
		(numeric -N equivalent)

The -I option will be documented on the elfdump(1) manpage, as follows:

	-I index-expr
		Qualifies a -c option, -p option, or -w option with a
		specific index or index range. For example, the third
		section header in a file can be displayed using:

		example% elfdump -c -I 3 filename

		An index-expr can be a single non-negative integer
		value that specifies a specific item, as shown in
		the previous example. Alternatively, an index-expr
		can consist of two such values separated by a colon (:),
		indicating a range of items. The following example
		displays the third, fourth, and fifth program headers
		in a file:

		example% elfdump -p -I 3:5 filename

		When specifying an index range, the second value can
		be omitted, to indicate the final item in the file.
		For example, the following statement lists all section
		headers from the tenth to the end:

		example% elfdump -c -I 10: filename

		The -I option can be used with the -N option. In addition,
		either option can be specified multiple times in order
		to select different items. These features allow for the
		selection of complex groupings of items.

Note that the behavior of elfdump when called with multiple -N options
is changed. In the past, the final such option was used, and any preceding
ones were quietly ignored. This was unspecified and undocumented
behavior, and without practical value. With the changes described in
this case, multiple -I and -N options are allowed, and each such option
adds a new "filter" to the list. This behavior, which will be documented
and committed, allows for relatively complex selection criteria. To make
this a little more concrete, consider the command:

     % elfdump -c -I 7 -N .dynstr -I 12:14 -I 26:  /bin/ls

This call lists:

     - section header [7]
     - The .dynstr section header (no matter what its index)
     - Section headers 12 through 14
     - All section headers starting at [26] and going to the end

The strings(1) command was recently given a -N option with meaning
similar to the elfdump(1) -N option (PSARC/2007/205). However,
strings(1) allows multiple -N options in a single command. This change
brings elfdump into line with that change, while also enhancing elfdump's
capabilities.

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

Release Binding:		Patch/Micro
-I elfdump option:		Committed


