5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright (c) 1989 AT&T
25 # Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
37 trap "rm -f $TDIR/$$symdef $TDIR/$$symref $TDIR/$$tmp; exit" 1 2 13 15
41 USAGE
="Usage: ${PFX}lorder file ..."
51 echo "${PFX}lorder: $i: cannot open"
64 # The following sed script is commented here.
65 # The first three expressions in the sed script
66 # insures that we only have lines
67 # that contain file names and the external
68 # declarations associated with each file.
69 # The next two parts of the sed script put the pattern
70 # (in this case the file name) into the hold space
71 # and creates the "filename filename" lines and
72 # writes them out. The first part is for .o files,
73 # the second is for .o's in archives.
74 # The last 2 sections of code are exactly alike but
75 # they handle different external symbols, namely the
76 # symbols that are defined in the text section, data section, bss
77 # section or common symbols and symbols
78 # that are referenced but not defined in this file.
79 # A line containing the symbol (from the pattern space) and
80 # the file it is referenced in (from the hold space) is
81 # put into the pattern space.
82 # If its text, data, bss or common it is written out to the
83 # symbol definition (symdef) file, otherwise it was referenced
84 # but not declared in this file so it is written out to the
85 # symbol referenced (symref) file.
88 ${WHERE}/${PFX}nm
-p $
* 2>$TDIR/$
$tmp |
sed -e '/^[ ]*$/d' -e '
121 if [ -s $TDIR/$
$tmp ]
123 sed -e "s/^${PFX}nm:/${PFX}lorder:/" < $TDIR/$
$tmp >&2
124 rm -f $TDIR/$
$symdef $TDIR/$
$symref $TDIR/$
$tmp
127 sort $TDIR/$
$symdef -o $TDIR/$
$symdef
128 sort $TDIR/$
$symref -o $TDIR/$
$symref
129 join $TDIR/$
$symref $TDIR/$
$symdef |
sed 's/[^ ]* *//'
130 rm -f $TDIR/$
$symdef $TDIR/$
$symref $TDIR/$
$tmp