Subject: bsd.lib.mk tweak for SHLIB_LD{START,END}FILE
To: None <tech-toolchain@netbsd.org>
From: Nathan J. Williams <nathanw@MIT.EDU>
List: tech-toolchain
Date: 10/19/2001 14:30:41
I recently found that rev 1.182 of bsd.lib.mk (from back in June)
inhibits the proper setting of SHLIB_LDSTARTFILE and SHLIB_LDENDFILE
on ELF platforms that aren't Alpha, MIPS, or VAX. The settings in
lines 131-134:


# Platform-independent flags for NetBSD a.out shared libraries (and
  PowerPC)
SHLIB_LDSTARTFILE=
SHLIB_LDENDFILE=

interact poorly with the slightly later:

.if ${OBJECT_FMT} == "ELF"
SHLIB_SOVERSION=        ${SHLIB_MAJOR}
SHLIB_SHFLAGS=          -soname lib${LIB}.so.${SHLIB_SOVERSION}
SHLIB_LDSTARTFILE?=     ${DESTDIR}/usr/lib/crtbeginS.o
SHLIB_LDENDFILE?=       ${DESTDIR}/usr/lib/crtendS.o
.endif

Since the latter two settings are ?=, they don't get set, and shared
libs don't get .init and .fini code on, say, i386 or m68k.

My proposed patch would be simply to remove the two blank settings
from the common section; the variables will still be empty in the
a.out case, and will get set properly in the ELF case. 

Does this seem like the proper fix?

        - Nathan

Index: bsd.lib.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.lib.mk,v
retrieving revision 1.185
diff -c -r1.185 bsd.lib.mk
*** bsd.lib.mk  2001/09/21 15:25:49     1.185
--- bsd.lib.mk  2001/10/19 18:24:16
***************
*** 130,137 ****
  .else
  
  # Platform-independent flags for NetBSD a.out shared libraries (and
    PowerPC)
- SHLIB_LDSTARTFILE=
- SHLIB_LDENDFILE=
  SHLIB_SOVERSION=${SHLIB_FULLVERSION}
  SHLIB_SHFLAGS=
  FPICFLAGS ?= -fPIC
--- 130,135 ----