Subject: bin/1791: lorder scripts break on NetBSD/pmax ELF
To: None <gnats-bugs@gnats.netbsd.org>
From: Jonathan Stone <jonathan@dsg.stanford.edu>
List: netbsd-bugs
Date: 11/25/1995 10:58:03
>Number:         1791
>Category:       bin
>Synopsis:       lorder scripts break on NetBSD/pmax ELF
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 25 14:20:01 1995
>Last-Modified:
>Originator:     Jonathan Stone
>Organization:
	Stanford DSG
>Release:        1.1
>Environment:
	
System: NetBSD Reno.Stanford.EDU 1.1 NetBSD 1.1 (NEWCONF) #0: Sat Nov 25 09:16:04 PST 1995 jonathan@Reno.Stanford.EDU:/usr/src/sys/arch/pmax/compile/NEWCONF pmax


>Description:
	NetBSD-1.1 installs the wrong (native-NM) script for
	NetBSD/pmax, which uses a GNU binutils ELF toolchain.
	Even if the ``gnu'' script is installed, not all dependencies
	are caught, and the performance of that script is unacceptable.

>How-To-Repeat:
	Build a user-land library on a stock NetBSD-1.1/pmax system.
	Note how some libraries (e.g., rcs) don't include all the
	requested .o files.
	Even if the "gnu-style" lorder script is installed, building
	large libraries (e.g., libc.a) takes approximately 20-50 times
	as long as with a BSD-style nm, due to the extra invokations
	of nm.
>Fix:
	The following patch to src/usr.bin/lorder/lorder.sh fixes
the above problems, by adding an explicit "for" loop that outputs
a dependency (suitable for tsort) for each input file.  This removes
any depencency on non-BSDish nm commands (e.g., binutils).
I think installing this patch, and eliminating the `alternative'
script, is a Good Idea regardless.

The patch also adds a test for "R" symbols (readonly constants).

There are more ELF symbols that could safely be added; I'm not sure
what a complete set is.

*** lorder.sh	Fri Oct 13 20:15:04 1995
--- lorder.sh.dsg	Sat Nov 25 10:48:47 1995
***************
*** 63,77 ****
  #
  # if the line has " U " it's a globally undefined symbol, put it into
  # the reference file.
! nm -go $* | sed "
  	/:$/ {
  		s/://
  		s/.*/& &/
  		p
  		d
  	}
! 	/ [TD] / {
! 		s/:.* [TD] / /
  		w $S
  		d
  	}
--- 63,77 ----
  #
  # if the line has " U " it's a globally undefined symbol, put it into
  # the reference file.
! (for file in $* ; do echo $file":" ; done ; nm -go $*) | sed "
  	/:$/ {
  		s/://
  		s/.*/& &/
  		p
  		d
  	}
! 	/ [TDR] / {
! 		s/:.* [TDR] / /
  		w $S
  		d
  	}
>Audit-Trail:
>Unformatted: