From: per@erix.ericsson.se (Per Hedeland)
Newsgroups: comp.sys.sun.admin
Subject: Re: : Re FIX for slow rebinding of NIS
Date: 28 Dec 92 14:49:04 GMT
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
Nntp-Posting-User: per

In article <1992Dec23.203057.17657@netnews.whoi.edu> eklein@whsun1.wh.whoi.edu (Edgar Kleindinst) writes:
>The only problem I've found is when I compile a program using 
>either gnu or cc I get this error
>
>ld: Undefined symbol
>   __mbstowcs_xccs
>   __mbtowc_xccs
>   __wcstombs_xccs
>   __wctomb_xccs

Sigh... I don't suppose Sun will ever get the /usr/lib/shlib.etc/README
file up-to-date - it certainly isn't as of 4.1.3. Below is a
customized-for-DNS version of it by Greg Earle, via Hal Stern - I
think... Check out item #3 (I think it said xccs_multibyte rather than
xccs.multibyte originally, an understandable typo).

--Per Hedeland


README------------------------------------------------------------------------
	This is a procedure you can use to substitute or add 
a module in your shared libc library. 

Note! If you are interested in a System V libc, please substitute
	libcs5_pic.a for libc_pic.a in step 3, and
	libcs5.so.x.y.z for libc.so.x.y.z in step 14.

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

1. Become super user
	% su

2. Make a temporary directory
	% mkdir tmp

3. Change to the "tmp" directory just made, extract the pic .o from 
   libc_pic.a and rm the file __.SYMDEF. The reason you need to do 
   the 2 "mv" commands is because "ar" truncated filenames over 
   16 characters.
	% cd tmp
	% ar x ../libc_pic.a
	% rm __.SYMDEF
	% mv rpc_dtablesize. rpc_dtablesize.o
	% mv rpc_commondata. rpc_commondata.o
	% mv xccs.multibyte. xccs.multibyte.o

   Note: this last mv command is not present in the original version of the
   README file that comes in /usr/lib/shlib.etc/README.  If this step is
   omitted, you will produce a shared libc.so that does not contain the
   xccs.multibyte.o module.  This module contains versions of the library
   functions "mbtowc", "wctomb", "mbstowcs" and "wcstombs" (see mblen(3) for
   more info on these multi-byte character functions), which operate on the
   Xerox XCCS codeset standard.  Specifically, the missing functions will be

	_mbtowc_xccs(pwc, s, n)
	_wctomb_xccs(s, pwc)
	_mbstowcs_xccs(pwc, s, n)
	_wcstombs_xccs(s, pwc, n)

   These are called by the corresponding "mbtowc", "wctomb", "mbstowcs" and
   "wcstombs" functions if the codeset is XCCS (other codesets include EUC,
   ISO 2022, and a default).  In short, if you use any Internationalization
   features and need to handle multi-byte character sets, do not forget this
   step.

4. If you are doing this to specifically create a libc.so that contains
   the DNS resolver routines for doing hostname/hostaddr lookups via the
   Domain Name Service (and not NIS/YP), do these additional steps.  If not,
   please skip down to step 10.

5. Extract the contents of /usr/lib/libresolv.a into the tmp directory:
	% ar x /usr/lib/libresolv.a
	% rm __.SYMDEF

   The libresolv.a contains object modules that are position
   independant, so they can be added to the libc_pic modules without fear.

   NOTE: You may wish to install Sun patch 100465-01 *first* before taking
   this step, as it provides a newer patched version of /usr/lib/libresolv.a.
   This fixes a serious bug that causes DNS nameserver lookups to fail if the
   first name server query yields ECONNREFUSED (Connection refused), even if
   the other nameservers specified in /etc/resolv.conf are both up & working:

Patch i.d.	Bug i.d's	SunOS	Description
----------	---------	-----	-----------
100465-01	1076977
			4.1 4.1 4.1.2 DNS res_send() fails if first nameserver
			in /etc/resolv.conf returns ECONNREFUSED

6. Remove the old routine to do the hostname/addr resolution:
	% rm gethostent.o

7. Remove the libresolv module that contains `strncasecmp' (which is now
   in the main C library, so it is redundant):
	% rm strcasecmp.o

8. As also mentioned below (in step 11), edit the file `lorder-sparc' in the ..
   directory.  Remove the reference to `gethostent.o' and add the
   references to the resolver library routines by applying this patch:

	% cd ..
	% diff -rc2 lorder-sparc.orig lorder-sparc
	*** lorder-sparc.orig   Thu Feb  8 05:27:46 1990
	--- lorder-sparc	Mon Apr  9 12:58:59 1990
	***************
	*** 150,154 ****
	  getwd.o
	  getnetgrent.o
	! gethostent.o
	  ypxdr.o
	  ttyname.o
	--- 150,161 ----
	  getwd.o
	  getnetgrent.o
	! gethostnamadr.o
	! sethostent.o
	! res_query.o
	! res_mkquery.o
	! res_send.o
	! res_debug.o
	! res_comp.o
	! res_init.o
	  ypxdr.o
	  ttyname.o

9. If you are running under SunOS 4.1.2, you will want to add the entry
   "mblib.o" to the very end of the "lorder-sparc" file.  If you aren't running
   SunOS 4.1.2, you may now skip down to step 13.

   Also, you will need to patch the Makefile, as follows:

	*** Makefile.orig	Wed Oct 23 10:13:00 1991
	--- Makefile	Mon Feb 24 18:38:08 1992
	***************
	*** 9,13 ****
	  
	  libc.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
	  	/bin/ls /usr/lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	--- 9,13 ----
	  
	  libc.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
	  	/bin/ls /usr/lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	***************
	*** 15,19 ****
	  
	  libcs5.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
	  	/bin/ls /usr/5lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
	--- 15,19 ----
	  
	  libcs5.so:
	! 	ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
	  	/bin/ls /usr/5lib/libc.so.* > TMP_FILE
	  	mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`

10. Replace or add the .o that you wanted by doing a copy. Please
    note here that you are advised to create your object with
    the following compiler option, i.e "cc -c -pic yourprogram.c" to make
    it shareable.
	% cp your.o .

11. If you add a new module then you need to do this step.
    You need to edit the file "lorder-sparc" and add the name of the file
    you have copied from step 4 at the end of this file. 
	% vi ../lorder-sparc

12. 	% cd ..

13. 	% make libc.so

14. Now you should have some libc.so.x.y.z built in the current directory.
    It is recommended that you tested out this library at this point 
    before installing it. You can do so by setting the environment
    LD_LIBRARY_PATH  to the current directory for example:
   	% setenv LD_LIBRARY_PATH `pwd`
	% your_favorite_test_cmd
    Once you are satisfied that the new library worked, you can proceed
    to install it with the following commands:
	% cp libc.so.x.y.z /usr/lib
	% ldconfig
	% unsetenv LD_LIBRARY_PATH

15. You are now running with the new library.  You can verify this by
    doing a trace command of, let's say, "date".
	% trace date
    The output should informed you that the new library is being used.
Xref: sparky comp.sys.sun.admin:9656 comp.sys.sun.misc:5951