diff -Nur toolchain.orig/binutils-2.9.1/libiberty/config/mh-cygwin32 toolchain/binutils-2.9.1/libiberty/config/mh-cygwin32 --- toolchain.orig/binutils-2.9.1/libiberty/config/mh-cygwin32 2001-11-02 00:03:30.000000000 +0000 +++ toolchain/binutils-2.9.1/libiberty/config/mh-cygwin32 2005-01-16 04:29:48.000000000 +0000 @@ -1,2 +1,5 @@ HDEFINES=-DNEED_sys_siglist -DNEED_basename -DNEED_strsignal EXTRA_OFILES=random.o +# --enable-auto-import is the default for Cygwin, but this removes info message +# that confuses check for dummy.c compilation messages for missing symbols +ERRORS_CC += -Wl,--enable-auto-import diff -Nur toolchain.orig/binutils-2.9.1/libiberty/functions.def toolchain/binutils-2.9.1/libiberty/functions.def --- toolchain.orig/binutils-2.9.1/libiberty/functions.def 2001-11-02 00:03:30.000000000 +0000 +++ toolchain/binutils-2.9.1/libiberty/functions.def 2005-01-16 04:29:48.000000000 +0000 @@ -35,7 +35,7 @@ DEF(strchr, char*, (s, c), CONST char *s AND int c) DEF(strdup, char*, (s1), char * s1) DEF(strrchr, char*, (s, c), CONST char *s AND int c) -DEF(strstr, char*, (), NOTHING) +DEF(strstr, char*, (h, n), CONST char *h AND CONST char *n) DEF(strtod, double, (), NOTHING) DEF(strtol, long, (), NOTHING) DEF(strtoul, unsigned long, (), NOTHING) diff -Nur toolchain.orig/binutils-2.9.1/libiberty/Makefile.in toolchain/binutils-2.9.1/libiberty/Makefile.in --- toolchain.orig/binutils-2.9.1/libiberty/Makefile.in 2001-11-02 00:03:30.000000000 +0000 +++ toolchain/binutils-2.9.1/libiberty/Makefile.in 2005-01-31 19:57:17.000000000 +0000 @@ -66,7 +66,7 @@ AR = ar AR_FLAGS = rc -ERRORS_CC = $(CC) +ERRORS_CC = $(CC) -fno-builtin CC = cc CFLAGS = -g LIBCFLAGS = $(CFLAGS) @@ -243,10 +243,11 @@ >>needed2.awk dummy.o: $(srcdir)/dummy.c $(srcdir)/functions.def - $(CC) -c $(CFLAGS) -I. -I$(INCDIR) $(HDEFINES) $(srcdir)/dummy.c 2>/dev/null + $(ERRORS_CC) -c $(CFLAGS) -I. -I$(INCDIR) $(HDEFINES) $(srcdir)/dummy.c 2>/dev/null errors: dummy.o $(EXTRA_OFILES) - -($(ERRORS_CC) -o dummy $(CFLAGS) $(LDFLAGS) $(ERRORS_LDFLAGS) dummy.o $(EXTRA_OFILES) $(LOADLIBES)) >errors 2>&1 || true + -($(ERRORS_CC) -o dummy $(CFLAGS) $(LDFLAGS) $(ERRORS_LDFLAGS) dummy.o $(EXTRA_OFILES) $(LOADLIBES)) 2>&1 \ + | grep -v deprecated >errors || true # required-list is used when building a shared bfd/opcodes/libiberty library. required-list: Makefile diff -Nur toolchain.orig/gcc-2.8.1/bc-typecd.def toolchain/gcc-2.8.1/bc-typecd.def --- toolchain.orig/gcc-2.8.1/bc-typecd.def 2001-11-02 00:08:54.000000000 +0000 +++ toolchain/gcc-2.8.1/bc-typecd.def 2002-02-04 16:56:03.000000000 +0000 @@ -14,7 +14,8 @@ DEFTYPECODE (SUcode, "SU", SImode, SUtype) DEFTYPECODE (DIcode, "DI", DImode, DItype) DEFTYPECODE (DUcode, "DU", DImode, DUtype) -DEFTYPECODE (SFcode, "SF", SFmode, SFtype) +/*DEFTYPECODE (SFcode, "SF", SFmode, SFtype)*/ +DEFTYPECODE (SFcode, "SF", SFmode, DFtype) DEFTYPECODE (DFcode, "DF", DFmode, DFtype) DEFTYPECODE (XFcode, "XF", XFmode, XFtype) DEFTYPECODE (Pcode, "P", PSImode, Ptype) diff -Nur toolchain.orig/gcc-2.8.1/config/i386/xm-cygwin32.h toolchain/gcc-2.8.1/config/i386/xm-cygwin32.h --- toolchain.orig/gcc-2.8.1/config/i386/xm-cygwin32.h 2001-11-02 00:08:56.000000000 +0000 +++ toolchain/gcc-2.8.1/config/i386/xm-cygwin32.h 2005-01-16 04:29:48.000000000 +0000 @@ -20,7 +20,3 @@ Boston, MA 02111-1307, USA. */ #define NO_STAB_H -#define EXECUTABLE_SUFFIX ".exe" - -/* Even though we support "/", allow "\" since everybody tests both. */ -#define DIR_SEPARATOR '\\' diff -Nur toolchain.orig/gcc-2.8.1/config/rs6000/linux.h toolchain/gcc-2.8.1/config/rs6000/linux.h --- toolchain.orig/gcc-2.8.1/config/rs6000/linux.h 2001-11-02 00:09:15.000000000 +0000 +++ toolchain/gcc-2.8.1/config/rs6000/linux.h 2006-01-23 22:28:53.000000000 +0000 @@ -23,7 +23,7 @@ #undef CPP_PREDEFINES #define CPP_PREDEFINES \ - "-DPPC -Dunix -Dlinux -Dpowerpc -Asystem(unix) -Asystem(linux) -Acpu(powerpc) -Amachine(powerpc)" + "-DPPC -Dunix -Dlinux -Dpowerpc -D__TIVO__ -Asystem(unix) -Asystem(linux) -Acpu(powerpc) -Amachine(powerpc)" #undef LINK_SPEC #define LINK_SPEC "-m elf32ppc %{shared:-shared} \ diff -Nur toolchain.orig/gcc-2.8.1/config/rs6000/sysv4.h toolchain/gcc-2.8.1/config/rs6000/sysv4.h --- toolchain.orig/gcc-2.8.1/config/rs6000/sysv4.h 2001-11-02 00:09:15.000000000 +0000 +++ toolchain/gcc-2.8.1/config/rs6000/sysv4.h 2006-01-23 22:27:13.000000000 +0000 @@ -1078,7 +1078,7 @@ %{mcall-sysv: -D_CALL_SYSV} %{mcall-nt: -D_CALL_NT} \ %{mcall-aix: -D_CALL_AIX} %{mcall-aixdesc: -D_CALL_AIX -D_CALL_AIXDESC} \ %{!mcall-sysv: %{!mcall-aix: %{!mcall-aixdesc: %{!mcall-nt: %(cpp_sysv_default) }}}} \ -%{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}" +%{!mhard-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}" #undef CPP_SYSV_DEFAULT_SPEC #define CPP_SYSV_DEFAULT_SPEC "-D_CALL_SYSV" diff -Nur toolchain.orig/gcc-2.8.1/libgcc2.c toolchain/gcc-2.8.1/libgcc2.c --- toolchain.orig/gcc-2.8.1/libgcc2.c 2001-11-02 00:09:18.000000000 +0000 +++ toolchain/gcc-2.8.1/libgcc2.c 2006-03-06 03:17:42.000000000 +0000 @@ -1033,8 +1033,8 @@ && DF_SIZE > (DI_SIZE - DF_SIZE + SF_SIZE)) { #define REP_BIT ((USItype) 1 << (DI_SIZE - DF_SIZE)) - if (! (- ((UDItype) 1 << DF_SIZE) < u - && u < ((UDItype) 1 << DF_SIZE))) + if (! (- ((DItype) 1 << DF_SIZE) < u + && u < ((DItype) 1 << DF_SIZE))) { if ((USItype) u & (REP_BIT - 1)) u |= REP_BIT; diff -Nur toolchain.orig/gcc-2.8.1/tivoCallGraph.c toolchain/gcc-2.8.1/tivoCallGraph.c --- toolchain.orig/gcc-2.8.1/tivoCallGraph.c 2001-11-02 00:09:19.000000000 +0000 +++ toolchain/gcc-2.8.1/tivoCallGraph.c 2002-02-04 17:13:48.000000000 +0000 @@ -1,3 +1,4 @@ +#include "config.h" #include "tivoDeclIter.h" #include diff -Nur toolchain.orig/gcc-2.8.1/tivoDeclIter.c toolchain/gcc-2.8.1/tivoDeclIter.c --- toolchain.orig/gcc-2.8.1/tivoDeclIter.c 2001-11-02 00:09:19.000000000 +0000 +++ toolchain/gcc-2.8.1/tivoDeclIter.c 2002-02-04 17:13:48.000000000 +0000 @@ -1,3 +1,4 @@ +#include "config.h" #include "tivoDeclIter.h" #include diff -Nur toolchain.orig/libc/Makefile toolchain/libc/Makefile --- toolchain.orig/libc/Makefile 2001-11-02 00:10:04.000000000 +0000 +++ toolchain/libc/Makefile 2006-04-09 21:59:32.000000000 +0000 @@ -104,6 +104,7 @@ generated := $(generated) munch-init.c endif +install-lib = libfix_tivo_libc.a libfix_tivo_libc_g.a include Makerules @@ -305,3 +306,47 @@ rpm/%: subdir_distinfo $(MAKE) -C $(@D) subdirs='$(subdirs)' $(@F) + + +# Build libfix_tivo_libc from:- +# 1) static versions of the NSS routines +# 2) the files, db, and dns NSS database implementations +# 3) libc modules that access the NSS routines +# 4) fixed stdlib/strtold.c and wcsmbs/wcstold.c + +libfix_tivo_libc-files:=grp/getgrent grp/getgrent_r grp/getgrgid grp/getgrgid_r grp/getgrnam grp/getgrnam_r grp/initgroups \ + inet/ether_hton inet/ether_ntoh inet/getaliasent inet/getaliasent_r inet/getaliasname \ + inet/getaliasname_r inet/gethstbyad inet/gethstbyad_r inet/gethstbynm inet/gethstbynm2 \ + inet/gethstbynm2_r inet/gethstbynm_r inet/gethstent inet/gethstent_r inet/getnetbyad \ + inet/getnetbyad_r inet/getnetbynm inet/getnetbynm_r inet/getnetent inet/getnetent_r \ + inet/getnetgrent inet/getnetgrent_r inet/getproto inet/getproto_r inet/getprtent inet/getprtent_r \ + inet/getprtname inet/getprtname_r inet/getrpcbyname inet/getrpcbyname_r inet/getrpcbynumber \ + inet/getrpcbynumber_r inet/getrpcent inet/getrpcent_r inet/getservent inet/getservent_r \ + inet/getsrvbynm inet/getsrvbynm_r inet/getsrvbypt inet/getsrvbypt_r inet/rcmd inet/rexec \ + misc/gethostid \ + nss/dns-host nss/dns-network nss/files-alias nss/files-ethers nss/files-grp nss/files-hosts \ + nss/files-netgrp nss/files-network nss/files-proto nss/files-pwd nss/files-rpc nss/files-service \ + nss/files-spwd nss/nsswitch \ + nss/alias-lookup-static-nss nss/ethers-lookup-static-nss nss/grp-lookup-static-nss \ + nss/hosts-lookup-static-nss nss/key-lookup-static-nss nss/netgrp-lookup-static-nss \ + nss/network-lookup-static-nss nss/proto-lookup-static-nss nss/pwd-lookup-static-nss \ + nss/rpc-lookup-static-nss nss/service-lookup-static-nss nss/spwd-lookup-static-nss \ + posix/getaddrinfo posix/glob \ + pwd/getpw pwd/getpwent pwd/getpwent_r pwd/getpwnam pwd/getpwnam_r pwd/getpwuid pwd/getpwuid_r \ + resolv/res_comp resolv/res_data resolv/res_debug-static-nss resolv/res_mkquery \ + resolv/res_query resolv/res_send \ + shadow/getspent shadow/getspent_r shadow/getspnam shadow/getspnam_r \ + stdio-common/cuserid \ + stdlib/strtold \ + sunrpc/clnt_gen sunrpc/clnt_simp sunrpc/getrpcport sunrpc/publickey \ + wcsmbs/wcstold + +$(objpfx)libfix_tivo_libc.a: $(addsuffix .o,$(addprefix $(objpfx), $(libfix_tivo_libc-files))) + $(AR) cru$(verbose) $@ $^ + +$(objpfx)libfix_tivo_libc_g.a: $(addsuffix .go,$(addprefix $(objpfx), $(libfix_tivo_libc-files))) + $(AR) cru$(verbose) $@ $^ + +# nis/libnss_nis.so needs nss/libnss_files.so, nss/libnss_dns.so needs resolv/libresolv.so +nis/others: nss/others +nss/others: resolv/others diff -Nur toolchain.orig/libc/Makerules toolchain/libc/Makerules --- toolchain.orig/libc/Makerules 2001-11-02 00:10:04.000000000 +0000 +++ toolchain/libc/Makerules 2006-02-19 15:47:58.000000000 +0000 @@ -352,9 +352,15 @@ ## $(elfobjdir)/sofini.so $(elfobjdir)/ld.so $(common-objpfx)libc.so: $(elfobjdir)/soinit.so \ $(common-objpfx)libc_pic.a \ - $(elfobjdir)/sofini.so $(elfobjdir)/ld2.so + $(elfobjdir)/sofini.so $(elfobjdir)/ld2.so \ + $(common-objpfx)libc_tramp.o $(build-shlib) +# Used by nss/nsswitch.c on TiVo. +GCC_SOURCE := $(..)../gcc-2.8.1 +$(common-objpfx)libc_tramp.S: $(GCC_SOURCE)/config/rs6000/tramp.asm + sed 's/__trampoline/__libc_trampoline/g' $< > $@ + ifdef libc.so-version $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so rm -f $@ diff -Nur toolchain.orig/libc/manual/stdio.texi toolchain/libc/manual/stdio.texi --- toolchain.orig/libc/manual/stdio.texi 2001-11-02 00:10:07.000000000 +0000 +++ toolchain/libc/manual/stdio.texi 2005-01-16 04:29:49.000000000 +0000 @@ -2234,9 +2234,9 @@ If you are trying to read input that doesn't match a single, fixed pattern, you may be better off using a tool such as Flex to generate a lexical scanner, or Bison to generate a parser, rather than using -@code{scanf}. For more information about these tools, see @ref{, , , -flex.info, Flex: The Lexical Scanner Generator}, and @ref{, , , -bison.info, The Bison Reference Manual}. +@code{scanf}. For more information about these tools, +see Flex: The Lexical Scanner Generator, +and The Bison Reference Manual. @node Input Conversion Syntax @subsection Input Conversion Syntax diff -Nur toolchain.orig/libc/nss/alias-lookup.c toolchain/libc/nss/alias-lookup.c --- toolchain.orig/libc/nss/alias-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/alias-lookup.c 2006-02-02 01:24:24.000000000 +0000 @@ -18,5 +18,8 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME aliases +#define STATIC_DEFS \ + DEFINE_ENT (files, alias) \ + DEFINE_GETBY (files, alias, name) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/ethers-lookup.c toolchain/libc/nss/ethers-lookup.c --- toolchain.orig/libc/nss/ethers-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/ethers-lookup.c 2006-02-02 01:16:19.000000000 +0000 @@ -18,5 +18,7 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME ethers +#define STATIC_DEFS \ + DEFINE_ENT (files, ether) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/grp-lookup.c toolchain/libc/nss/grp-lookup.c --- toolchain.orig/libc/nss/grp-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/grp-lookup.c 2006-02-02 01:20:17.000000000 +0000 @@ -18,5 +18,9 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME group +#define STATIC_DEFS \ + DEFINE_ENT (files, gr) \ + DEFINE_GET (files, grgid) \ + DEFINE_GET (files, grnam) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/hosts-lookup.c toolchain/libc/nss/hosts-lookup.c --- toolchain.orig/libc/nss/hosts-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/hosts-lookup.c 2006-02-02 01:34:45.000000000 +0000 @@ -19,5 +19,14 @@ #define DATABASE_NAME hosts #define DEFAULT_CONFIG "dns [!UNAVAIL=return] files" +#define STATIC_DEFS \ + DEFINE_ENT (files, host) \ + DEFINE_GETBY (files, host, addr) \ + DEFINE_GETBY (files, host, name) \ + DEFINE_GET (files, hostton) \ + DEFINE_GET (files, ntohost) \ + DEFINE_GETBY (dns, host, addr) \ + DEFINE_GETBY (dns, host, name) \ + DEFINE_GETBY (dns, host, name2) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/Makefile toolchain/libc/nss/Makefile --- toolchain.orig/libc/nss/Makefile 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/Makefile 2006-04-09 22:14:30.000000000 +0000 @@ -63,7 +63,6 @@ libnss_dns-inhibit-o = $(filter-out .so,$(object-suffixes)) libnss_db-inhibit-o = $(filter-out .so,$(object-suffixes)) - include ../Rules @@ -82,3 +81,12 @@ # This ensures they will load libc.so for needed symbols if loaded by # a statically-linked program that hasn't already loaded it. $(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so + +# Extra routines needed by libfix_tivo_libc. +libfix_tivo_libc-routines := $(libnss_files-routines) $(libnss_dns-routines) $(libnss_db-routines) +libfix_tivo_libc-routines += $(addsuffix -lookup-static-nss,$(databases)) + +subdir_lib: $(addprefix $(objpfx),$(foreach o,.o .go,$(addsuffix $(o),$(libfix_tivo_libc-routines)))) + +$(objpfx)%-static-nss.o: %.c $(before-compile); $(compile-command.c) -DDO_STATIC_NSS +$(objpfx)%-static-nss.go: %.c $(before-compile); $(compile-command.c) -DDO_STATIC_NSS diff -Nur toolchain.orig/libc/nss/netgrp-lookup.c toolchain/libc/nss/netgrp-lookup.c --- toolchain.orig/libc/nss/netgrp-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/netgrp-lookup.c 2006-02-02 01:21:04.000000000 +0000 @@ -18,5 +18,7 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME netgroup +#define STATIC_DEFS \ + DEFINE_ENT (files, netgr) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/network-lookup.c toolchain/libc/nss/network-lookup.c --- toolchain.orig/libc/nss/network-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/network-lookup.c 2006-02-02 01:21:46.000000000 +0000 @@ -19,5 +19,11 @@ #define DATABASE_NAME networks #define DEFAULT_CONFIG "dns files" +#define STATIC_DEFS \ + DEFINE_ENT (files, net) \ + DEFINE_GETBY (files, net, name) \ + DEFINE_GETBY (files, net, addr) \ + DEFINE_GETBY (dns, net, name) \ + DEFINE_GETBY (dns, net, addr) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/nsswitch.c toolchain/libc/nss/nsswitch.c --- toolchain.orig/libc/nss/nsswitch.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/nsswitch.c 2006-02-19 15:02:55.000000000 +0000 @@ -30,7 +30,18 @@ #include "nsswitch.h" +#if defined(__TIVO__) && defined(PIC) +/* Use a private version of __trampoline_setup (used to call + * nss_lookup_function's nested functions do_open and get_sym from inside + * nss_dlerror_run). Using this private libc_tramp.S prevents libc.so from + * exporting dynamic symbols __trampoline_initial and __trampoline_setup, + * which can be incompatible with TiVo's original libc.so, which doesn't. + */ +__asm__(".set __trampoline_setup,__libc_trampoline_setup"); +#endif + /* Prototypes for the local functions. */ +static known_function* nss_search (service_user *ni, const char *fct_name, int *oldfunc); static void *nss_lookup_function (service_user *ni, const char *fct_name); static name_database *nss_parse_file (const char *fname); static name_database_entry *nss_getline (char *line); @@ -70,7 +81,6 @@ /* The root of the whole data base. */ static name_database *service_table; - /* -1 == database not found 0 == database entry pointer stored */ int @@ -260,14 +270,13 @@ } -static void * -nss_lookup_function (service_user *ni, const char *fct_name) +static known_function* +nss_search (service_user *ni, const char *fct_name, int *oldfunc) { -#if 0 - void **found, *result; + known_function *known; + void **found; - /* We now modify global data. Protect it. */ - __libc_lock_lock (lock); + *oldfunc = 0; /* Search the tree of functions previously requested. Data in the tree are `known_function' structures, whose first member is a @@ -279,49 +288,68 @@ will be passed to `known_compare' (above). */ found = __tsearch (&fct_name, (void **) &ni->known, &known_compare); + if (found == NULL) return NULL; /* tsearch ran out of memory */ if (*found != &fct_name) - /* The search found an existing structure in the tree. */ - result = ((known_function *) *found)->fct_ptr; - else { - /* This name was not known before. Now we have a node in the tree - (in the proper sorted position for FCT_NAME) that points to - &FCT_NAME instead of any real `known_function' structure. - Allocate a new structure and fill it in. */ + /* The search found an existing structure in the tree. */ + *oldfunc = 1; + return *found; + } + + /* This name was not known before. Now we have a node in the tree + (in the proper sorted position for FCT_NAME) that points to + &FCT_NAME instead of any real `known_function' structure. + Allocate a new structure and fill it in. */ + + known = malloc (sizeof *known); + if (known) { + static name_database default_table; + + /* Point the tree node at this new structure. */ + *found = known; + known->fct_name = fct_name; + known->fct_ptr = NULL; + + if (ni->library != NULL) return known; + + /* This service has not yet been used. Fetch the service + library for it, creating a new one if need be. If there + is no service table from the file, this static variable + holds the head of the service_library list made from the + default configuration. */ + ni->library = nss_new_service (service_table ?: &default_table, + ni->name); + if (ni->library != NULL) return known; - known_function *known = malloc (sizeof *known); - if (! known) - { - remove_from_tree: - /* Oops. We can't instantiate this node properly. - Remove it from the tree. */ - __tdelete (&fct_name, (void **) &ni->known, &known_compare); - result = NULL; - } - else - { - /* Point the tree node at this new structure. */ - *found = known; - known->fct_name = fct_name; + /* This only happens when out of memory. */ + free (known); + } - if (ni->library == NULL) - { - /* This service has not yet been used. Fetch the service - library for it, creating a new one if need be. If there - is no service table from the file, this static variable - holds the head of the service_library list made from the - default configuration. */ - static name_database default_table; - ni->library = nss_new_service (service_table ?: &default_table, - ni->name); - if (ni->library == NULL) - { - /* This only happens when out of memory. */ - free (known); - goto remove_from_tree; - } - } + /* Oops. We can't instantiate this node properly. + Remove it from the tree. */ + __tdelete (&fct_name, (void **) &ni->known, &known_compare); + return NULL; +} + + +static void * +nss_lookup_function (service_user *ni, const char *fct_name) +{ + void *result; + known_function *known; + int oldfunc; + + /* We now modify global data. Protect it. */ + __libc_lock_lock (lock); + + known = nss_search (ni, fct_name, &oldfunc); + if (known == NULL) + result = NULL; + else if (oldfunc) + result = known->fct_ptr; + else + { if (ni->library->lib_handle == NULL) { /* Load the shared library. */ @@ -386,14 +414,35 @@ /* Remember function pointer for later calls. Even if null, we record it so a second try needn't search the library again. */ known->fct_ptr = result; - } } /* Remove the lock. */ __libc_lock_unlock (lock); return result; -#endif +} + + +void +__nss_add_functions (service_user *ni, const static_function *fcts) +{ + /* We now modify global data. Protect it. */ + __libc_lock_lock (lock); + + for (; ni; ni = ni->next) { + const static_function *tp; + for (tp = fcts; tp->library; tp++) + if (strcmp (tp->library, ni->name) == 0) { + int oldfunc; + known_function *known = nss_search (ni, tp->fct.fct_name, &oldfunc); + if (known && !oldfunc) known->fct_ptr = tp->fct.fct_ptr; + } + } + + /* Remove the lock. */ + __libc_lock_unlock (lock); + + return; } diff -Nur toolchain.orig/libc/nss/nsswitch.h toolchain/libc/nss/nsswitch.h --- toolchain.orig/libc/nss/nsswitch.h 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/nsswitch.h 2006-02-02 02:46:28.000000000 +0000 @@ -95,6 +95,11 @@ } name_database; +typedef struct static_function { + const char *library; + const known_function fct; +} static_function; + /* Interface functions for NSS. */ /* Get the data structure representing the specified database. @@ -126,5 +131,6 @@ int __nss_next (service_user **ni, const char *fct_name, void **fctp, int status, int all_values); +void __nss_add_functions (service_user *ni, const static_function *fcts); #endif /* nsswitch.h */ diff -Nur toolchain.orig/libc/nss/proto-lookup.c toolchain/libc/nss/proto-lookup.c --- toolchain.orig/libc/nss/proto-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/proto-lookup.c 2006-02-02 01:22:07.000000000 +0000 @@ -18,5 +18,9 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME protocols +#define STATIC_DEFS \ + DEFINE_ENT (files, proto) \ + DEFINE_GETBY (files, proto, name) \ + DEFINE_GETBY (files, proto, number) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/pwd-lookup.c toolchain/libc/nss/pwd-lookup.c --- toolchain.orig/libc/nss/pwd-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/pwd-lookup.c 2006-02-02 01:22:29.000000000 +0000 @@ -18,5 +18,9 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME passwd +#define STATIC_DEFS \ + DEFINE_ENT (files, pw) \ + DEFINE_GET (files, pwnam) \ + DEFINE_GET (files, pwuid) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/rpc-lookup.c toolchain/libc/nss/rpc-lookup.c --- toolchain.orig/libc/nss/rpc-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/rpc-lookup.c 2006-02-02 01:37:02.000000000 +0000 @@ -18,5 +18,9 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME rpc +#define STATIC_DEFS \ + DEFINE_ENT (files, rpc) \ + DEFINE_GETBY (files, rpc, name) \ + DEFINE_GETBY (files, rpc, number) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/service-lookup.c toolchain/libc/nss/service-lookup.c --- toolchain.orig/libc/nss/service-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/service-lookup.c 2006-02-02 01:22:47.000000000 +0000 @@ -18,5 +18,9 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME services +#define STATIC_DEFS \ + DEFINE_ENT (files, serv) \ + DEFINE_GETBY (files, serv, name) \ + DEFINE_GETBY (files, serv, port) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/spwd-lookup.c toolchain/libc/nss/spwd-lookup.c --- toolchain.orig/libc/nss/spwd-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/spwd-lookup.c 2006-02-02 01:23:08.000000000 +0000 @@ -18,5 +18,8 @@ Boston, MA 02111-1307, USA. */ #define DATABASE_NAME shadow +#define STATIC_DEFS \ + DEFINE_ENT (files, sp) \ + DEFINE_GET (files, spnam) #include "XXX-lookup.c" diff -Nur toolchain.orig/libc/nss/XXX-lookup.c toolchain/libc/nss/XXX-lookup.c --- toolchain.orig/libc/nss/XXX-lookup.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/nss/XXX-lookup.c 2006-02-02 02:49:04.000000000 +0000 @@ -25,9 +25,10 @@ |* DATABASE_NAME - name of the database the function accesses *| |* (e.g., hosts, servicess, ...) *| |* *| -|* One additional symbol may optionally be defined: *| +|* Additional symbols may optionally be defined: *| |* *| |* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *| +|* STATIC_DEFS - specification of static NSS routines *| |* *| \*******************************************************************/ @@ -46,13 +47,41 @@ service_user *DATABASE_NAME_SYMBOL = NULL; +#if defined(DO_STATIC_NSS) && defined(STATIC_DEFS) +/* STATIC_DEFS contains one or more DEFINE_ENT, DEFINE_GET, and DEFINE_GETBY + * clauses that specify the routines to statically reference here. + * (Adapted from glibc 2.3.6's function.def). +*/ +# define DEFINE_ENT(h,nm) USE_FCT(h,get##nm##ent_r) \ + USE_FCT(h,end##nm##ent) \ + USE_FCT(h,set##nm##ent) +# define DEFINE_GET(h,nm) USE_FCT(h,get##nm##_r) +# define DEFINE_GETBY(h,nm,ky) USE_FCT(h,get##nm##by##ky##_r) + +/* Declare functions. */ +# define USE_FCT(h,n) extern enum nss_status _nss_##h##_##n(); +STATIC_DEFS +# undef USE_FCT + +/* Create lookup table. */ +# define USE_FCT(h,n) { #h, { #n, _nss_##h##_##n } }, +static const static_function database_fcts[] = { +STATIC_DEFS + { NULL, { NULL, NULL } } +}; +#endif + int DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp) { - if (DATABASE_NAME_SYMBOL == NULL - && __nss_database_lookup (DATABASE_NAME_STRING, DEFAULT_CONFIG, - &DATABASE_NAME_SYMBOL) < 0) - return -1; + if (DATABASE_NAME_SYMBOL == NULL) { + if (__nss_database_lookup (DATABASE_NAME_STRING, DEFAULT_CONFIG, + &DATABASE_NAME_SYMBOL) < 0) + return -1; +#if defined(DO_STATIC_NSS) && defined(STATIC_DEFS) + __nss_add_functions (DATABASE_NAME_SYMBOL, database_fcts); +#endif + } *ni = DATABASE_NAME_SYMBOL; diff -Nur toolchain.orig/libc/resolv/Makefile toolchain/libc/resolv/Makefile --- toolchain.orig/libc/resolv/Makefile 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/resolv/Makefile 2006-04-09 22:10:57.000000000 +0000 @@ -48,3 +48,11 @@ # This ensures they will load libc.so for needed symbols if loaded by # a statically-linked program that hasn't already loaded it. $(objpfx)libresolv.so: $(common-objpfx)libc.so + +# Extra routines needed by libfix_tivo_libc. +libfix_tivo_libc-routines := res_debug-static-nss + +subdir_lib: $(addprefix $(objpfx),$(foreach o,.o .go,$(addsuffix $(o),$(libfix_tivo_libc-routines)))) + +$(objpfx)%-static-nss.o: %.c $(before-compile); $(compile-command.c) -DDO_STATIC_NSS +$(objpfx)%-static-nss.go: %.c $(before-compile); $(compile-command.c) -DDO_STATIC_NSS diff -Nur toolchain.orig/libc/resolv/res_debug.c toolchain/libc/resolv/res_debug.c --- toolchain.orig/libc/resolv/res_debug.c 2001-11-02 00:10:08.000000000 +0000 +++ toolchain/libc/resolv/res_debug.c 2006-04-09 21:55:37.000000000 +0000 @@ -104,6 +104,7 @@ # include "../conf/options.h" #endif +#ifndef DO_STATIC_NSS extern const char *_res_opcodes[]; extern const char *_res_resultcodes[]; @@ -869,6 +870,7 @@ } return (cp); } +#endif /* !DO_STATIC_NSS */ /* * Names of RR classes and qclasses. Classes and qclasses are the same, except @@ -939,6 +941,7 @@ {0, NULL, NULL} }; +#ifndef DO_STATIC_NSS int __sym_ston(syms, name, success) const struct res_sym *syms; @@ -961,6 +964,7 @@ *success = 0; return (syms->number); /* The default value. */ } +#endif /* !DO_STATIC_NSS */ const char * __sym_ntos(syms, number, success) @@ -990,6 +994,7 @@ } +#ifndef DO_STATIC_NSS const char * __sym_ntop(syms, number, success) const struct res_sym *syms; @@ -1015,6 +1020,7 @@ *success = 0; return (unname); } +#endif /* !DO_STATIC_NSS */ /* * Return a string for the type @@ -1036,6 +1042,7 @@ return (__sym_ntos (__p_class_syms, class, (int *)0)); } +#ifndef DO_STATIC_NSS /* * Return a mnemonic for an option */ @@ -1545,3 +1552,4 @@ time.tm_hour, time.tm_min, time.tm_sec); return (output); } +#endif /* !DO_STATIC_NSS */ diff -Nur toolchain.orig/libc/stdio-common/Makefile toolchain/libc/stdio-common/Makefile --- toolchain.orig/libc/stdio-common/Makefile 2001-11-02 00:10:14.000000000 +0000 +++ toolchain/libc/stdio-common/Makefile 2005-01-16 04:29:49.000000000 +0000 @@ -55,7 +55,8 @@ CFLAGS-scanf7.c = -Wno-format # GCC optimizer bug -CFLAGS-vfscanf.c += -O0 +CFLAGS-vfscanf.c += -fno-schedule-insns -fno-schedule-insns2 +CFLAGS-vfprintf.c += -fno-schedule-insns -fno-schedule-insns2 ifeq ($(stdio),libio) ifneq (,$(filter %REENTRANT, $(defines))) diff -Nur toolchain.orig/libc/stdlib/strtold.c toolchain/libc/stdlib/strtold.c --- toolchain.orig/libc/stdlib/strtold.c 2001-11-02 00:10:15.000000000 +0000 +++ toolchain/libc/stdlib/strtold.c 2006-04-01 16:03:15.000000000 +0000 @@ -1,3 +1,4 @@ +#ifndef __powerpc__ /* The actual implementation for all floating point sizes is in strtod.c. These macros tell it to produce the `long double' version, `strtold'. */ @@ -8,3 +9,18 @@ #define FLOAT_HUGE_VAL HUGE_VALl #include "strtod.c" +#else +/* There is no `long double' type, use the `double' implementations. */ +#include +long double +__strtold_internal (const char *nptr, char **endptr, int group) +{ + return __strtod_internal (nptr, endptr, group); +} + +long double +strtold (const char *nptr, char **endptr) +{ + return __strtod_internal (nptr, endptr, 0); +} +#endif diff -Nur toolchain.orig/libc/sunrpc/Makefile toolchain/libc/sunrpc/Makefile --- toolchain.orig/libc/sunrpc/Makefile 2001-11-02 00:10:15.000000000 +0000 +++ toolchain/libc/sunrpc/Makefile 2002-02-04 19:47:05.000000000 +0000 @@ -117,13 +117,15 @@ $(objpfx)rpcsvc/%.h: rpcsvc/%.x $(objpfx)rpcgen $(make-target-directory) -@rm -f $@T - $(rpcgen-cmd) -h $< -o $@T +# $(rpcgen-cmd) -h $< -o $@T + /usr/bin/rpcgen -h $< -o $@T mv -f $@T $@ # Generate the rpcsvc XDR functions with rpcgen. $(objpfx)x%.c: rpcsvc/%.x $(objpfx)rpcgen -@rm -f $@T - $(rpcgen-cmd) -c $< -o $@T +# $(rpcgen-cmd) -c $< -o $@T + /usr/bin/rpcgen -c $< -o $@T mv -f $@T $@ # The generated source files depend on the corresponding generated headers. diff -Nur toolchain.orig/libc/sysdeps/powerpc/bytesex.h toolchain/libc/sysdeps/powerpc/bytesex.h --- toolchain.orig/libc/sysdeps/powerpc/bytesex.h 1970-01-01 00:00:00.000000000 +0000 +++ toolchain/libc/sysdeps/powerpc/bytesex.h 2006-01-23 04:08:02.000000000 +0000 @@ -0,0 +1 @@ +#define __BYTE_ORDER __BIG_ENDIAN diff -Nur toolchain.orig/libc/sysdeps/powerpc/elf/Makefile toolchain/libc/sysdeps/powerpc/elf/Makefile --- toolchain.orig/libc/sysdeps/powerpc/elf/Makefile 2001-11-02 00:10:20.000000000 +0000 +++ toolchain/libc/sysdeps/powerpc/elf/Makefile 2006-03-19 22:14:08.000000000 +0000 @@ -3,11 +3,13 @@ extra-objs += crtbegin.o crtend.o crtbeginS.o crtendS.o install-lib += crtbegin.o crtend.o crtbeginS.o crtendS.o -crtbeginS.o: crtbegin.so - cp crtbegin.so crtbeginS.o +$(objpfx)crtbeginS.o: $(objpfx)crtbegin.so + cp $(objpfx)crtbegin.so $(objpfx)crtbeginS.o + touch $(objpfx)crtbeginS.d -crtendS.o: crtend.so - cp crtend.so crtendS.o +$(objpfx)crtendS.o: $(objpfx)crtend.so + cp $(objpfx)crtend.so $(objpfx)crtendS.o + touch $(objpfx)crtendS.d endif diff -Nur toolchain.orig/libc/wcsmbs/wcstold.c toolchain/libc/wcsmbs/wcstold.c --- toolchain.orig/libc/wcsmbs/wcstold.c 2001-11-02 00:10:23.000000000 +0000 +++ toolchain/libc/wcsmbs/wcstold.c 2006-04-01 16:03:37.000000000 +0000 @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ +#ifndef __powerpc__ /* The actual implementation for all floating point sizes is in strtod.c. These macros tell it to produce the `long double' version, `wcstold'. */ @@ -29,3 +30,18 @@ #define USE_WIDE_CHAR 1 #include "../stdlib/strtod.c" +#else +/* There is no `long double' type, use the `double' implementations. */ +#include +long double +__wcstold_internal (const wchar_t *nptr, wchar_t **endptr, int group) +{ + return __wcstod_internal (nptr, endptr, group); +} + +long double +wcstold (const wchar_t *nptr, wchar_t **endptr) +{ + return __wcstod_internal (nptr, endptr, 0); +} +#endif