From 78de391d385a134571247f17061b95290c819f9e Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 9 Feb 2005 00:11:14 +0000 Subject: [PATCH] Build system support for a library having more than one init/fini symbol defined, when using linker options to specify these functions. Now LIBINITFUNC/LIBFINIFUNC are considered lists of symbols, ordered from lowest-level (init run first, fini run last) to highest-level. * lib.in (config.status): Change target to be in $thisconfigdir rather than local. (osf1.exports): Create a temporary file then rename into place. Add options for library init/fini symbols, handling multiple values. * shlib.conf (case alpha*-dec-osf*): Don't handle init/fini symbols here. (case mips-sgi-irix*): Handle multiple init/fini symbols. Always set $initfini before it gets used. (case *-*-solaris*, not gcc): Handle multiple init/fini symbols. (case *-*-aix*): Handle multiple fini symbols. ticket: 2916 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17088 dc483132-0cff-0310-8789-dd5450dbe970 --- src/config/ChangeLog | 15 +++++++++++++++ src/config/lib.in | 17 +++++++++++++++-- src/config/shlib.conf | 15 +++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/config/ChangeLog b/src/config/ChangeLog index c916d9cbe..7950df236 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,3 +1,18 @@ +2005-02-08 Ken Raeburn + + * lib.in (config.status): Change target to be in $thisconfigdir + rather than local. + (osf1.exports): Create a temporary file then rename into place. + Add options for library init/fini symbols, handling multiple + values. + + * shlib.conf (case alpha*-dec-osf*): Don't handle init/fini + symbols here. + (case mips-sgi-irix*): Handle multiple init/fini symbols. Always + set $initfini before it gets used. + (case *-*-solaris*, not gcc): Handle multiple init/fini symbols. + (case *-*-aix*): Handle multiple fini symbols. + 2005-01-24 Ken Raeburn * post.in (Makefile): Nuke autom4te.cache before and after diff --git a/src/config/lib.in b/src/config/lib.in index 7ebdb3ff3..eea4601d5 100644 --- a/src/config/lib.in +++ b/src/config/lib.in @@ -57,7 +57,20 @@ binutils.versions: $(SHLIB_EXPORT_FILE) Makefile echo >> binutils.versions "};" osf1.exports: $(SHLIB_EXPORT_FILE) Makefile - sed "s/^/-exported_symbol /" < $(SHLIB_EXPORT_FILE) > osf1.exports + $(RM) osf1.tmp osf1.exports + sed "s/^/-exported_symbol /" < $(SHLIB_EXPORT_FILE) > osf1.tmp + for f in . $(LIBINITFUNC); do \ + if test "$$f" != "." ; then \ + echo " -init $$f"__auxinit >> osf1.tmp; \ + else :; fi; \ + done + a=""; \ + for f in . $(LIBFINIFUNC); do \ + if test "$$f" != "." ; then \ + a="-fini $$f $$a"; \ + else :; fi; \ + done; echo " $$a" >> osf1.tmp; \ + mv -f osf1.tmp osf1.exports lib$(LIBBASE)$(PFLIBEXT): $(PFOBJLISTS) $(RM) $@ @@ -120,7 +133,7 @@ install-profiled: $(RANLIB) $(DESTDIR)$(KRB5_LIBDIR)/lib$(LIBBASE)$(PFLIBEXT) Makefile: $(SRCTOP)/config/lib.in -config.status: $(SRCTOP)/config/shlib.conf +$(thisconfigdir)/config.status: $(SRCTOP)/config/shlib.conf # Use the following if links need to be made to $(TOPLIBD): # all-unix:: all-liblinks diff --git a/src/config/shlib.conf b/src/config/shlib.conf index f5c6b8405..4d09e84e4 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -38,7 +38,7 @@ alpha*-dec-osf*) SHLIBEXT=.so # Alpha OSF/1 doesn't need separate PIC objects SHOBJEXT=.o - INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=""; else initfini="-Wl,-init,$(LIBINITFUNC)__auxinit"; fi; if test -z "$(LIBFINIFUNC)";then :;else initfini="$$initfini -Wl,-fini,$(LIBFINIFUNC)"; fi' + INIT_FINI_PREP=initfini= LDCOMBINE='$(CC) $(PTHREAD_CFLAGS) -shared -Wl,-expect_unresolved -Wl,\* -Wl,-update_registry -Wl,$(BUILDTOP)/so_locations -Wl,-soname -Wl,lib$(LIBBASE)$(SHLIBSEXT) -Wl,-hidden -Wl,-input,osf1.exports $$initfini' SHLIB_EXPORT_FILE_DEP=osf1.exports use_linker_init_option=yes @@ -139,10 +139,11 @@ mips-sgi-irix*) SHOBJEXT=.o if test "$krb5_cv_prog_gcc" = yes; then LDCOMBINE_TAIL="" + INIT_FINI_PREP="initfini=" else use_linker_init_option=yes use_linker_fini_option=yes - INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=""; else initfini="-Wl,-init,$(LIBINITFUNC)__auxinit"; fi; if test -z "$(LIBFINIFUNC)";then :;else initfini="$$initfini -Wl,-fini,$(LIBFINIFUNC)"; fi' + INIT_FINI_PREP='initfini=; for f in . $(LIBINITFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-init,$${f}__auxinit"; fi; done; for f in . $(LIBFINIFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-fini,$${f}"; fi; done' LDCOMBINE_TAIL='-Wl,-exports_file -Wl,$(SHLIB_EXPORT_FILE)' fi LDCOMBINE='$(CC) -shared -Wl,-ignore_unresolved -Wl,-update_registry -Wl,$(BUILDTOP)/so_locations -Wl,-soname -Wl,lib$(LIBBASE)$(SHLIBSEXT) $$initfini' @@ -279,6 +280,7 @@ mips-*-netbsd*) LDCOMBINE='$(CC) -dy -G -z text -h lib$(LIBBASE)$(SHLIBSEXT) $$initfini' # INIT_FINI_PREP='if test -z "$(LIBINITFUNC)"; then initfini=; else initfini="-Wl,-z,initarray=$(LIBINITFUNC)__auxinit"; fi ; if test -z "$(LIBFINIFUNC)"; then :; else initfini="$$initfini -Wl,-z,finiarray=$(LIBFINIFUNC)" ; fi' + INIT_FINI_PREP='initfini=; for f in . $(LIBINITFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-z,initarray=$${f}__auxinit"; fi; done; for f in . $(LIBFINIFUNC); do if test $$f = .; then :; else initfini="$$initfini -Wl,-z,finiarray=$$f"; fi; done' use_linker_init_option=yes use_linker_fini_option=yes fi @@ -351,16 +353,17 @@ mips-*-netbsd*) SHLIB_EXPFLAGS=' $(SHLIB_DIRS) $(SHLIB_EXPLIBS)' PROFFLAGS=-pg if test "$krb5_cv_prog_gcc" = "yes" ; then + wl_prefix=-Wl, RPATH_FLAG='-Wl,-blibpath:' LDCOMBINE='$(CC) -shared -v -o shr.o.$(LIBMAJOR).$(LIBMINOR) $$objlist -nostartfiles -Xlinker -bgcbypass:1 -Xlinker -bfilelist -Xlinker -bM:SRE -Xlinker -bE:$(SHLIB_EXPORT_FILE) -Xlinker -bernotok $(SHLIB_EXPFLAGS) -lc $$initfini' - INIT_FINI_PREP='if test -z "$(LIBFINIFUNC)"; then initfini=""; else initfini="-Wl,-binitfini::$(LIBFINIFUNC):3"; fi' - use_linker_fini_option=yes else + wl_prefix= RPATH_FLAG=-blibpath: LDCOMBINE='/bin/ld -o shr.o.$(LIBMAJOR).$(LIBMINOR) $$objlist -H512 -T512 -bnoentry -bgcbypass:1 -bnodelcsect -bfilelist -bM:SRE -bE:$(SHLIB_EXPORT_FILE) -bernotok $(SHLIB_EXPFLAGS) -lc $$initfini' - INIT_FINI_PREP='if test -z "$(LIBFINIFUNC)"; then initfini=""; else initfini="-binitfini::$(LIBFINIFUNC):3"; fi' - use_linker_fini_option=yes fi + # Assume initialization always delayed. + INIT_FINI_PREP="wl=${wl_prefix}; "'i=1; initfini=; for f in . $(LIBFINIFUNC); do if test $$f != .; then initfini="$$initfini $${wl}-binitfini::$$f:$$i"; else :; fi; i=`expr $$i + 1`; done' + use_linker_fini_option=yes MAKE_SHLIB_COMMAND="${INIT_FINI_PREP} && ${LDCOMBINE}"' && ar cq $@ shr.o.$(LIBMAJOR).$(LIBMINOR) && chmod +x $@ && rm -f shr.o.$(LIBMAJOR).$(LIBMINOR)' RPATH_TAIL=:/usr/lib:/lib CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) $(RPATH_FLAG)$(PROG_RPATH):'"$RPATH_TAIL"' $(CFLAGS) $(LDFLAGS)' -- 2.26.2