# DIY Linux Patch
Date: 2005-03-29
Author: Refer Description
Origin: Refer Description
Maker: Greg Schafer <gschafer@zip.com.au>
Upstream Status: Refer Description
Description: Fix compilation with GCC4

http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00816.html
http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00815.html
http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00500.html
http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00501.html
  (x86 portion only + adjusted for stable branch)
http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00720.html
http://sources.redhat.com/ml/glibc-cvs/2005-q1/msg00302.html

diff -Naur glibc-2.3-20050314.orig/elf/dynamic-link.h glibc-2.3-20050314/elf/dynamic-link.h
--- glibc-2.3-20050314.orig/elf/dynamic-link.h	2004-09-24 17:09:03.000000000 +0000
+++ glibc-2.3-20050314/elf/dynamic-link.h	2005-03-28 22:58:14.000000000 +0000
@@ -1,5 +1,5 @@
 /* Inline functions for dynamic linking.
-   Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,20 +31,24 @@
    optimizing away alignment tests or using word instructions for
    copying memory, breaking the very code written to handle the
    unaligned cases.  */
+# if ! ELF_MACHINE_NO_REL
 auto void __attribute__((always_inline))
 elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
 		 const ElfW(Sym) *sym, const struct r_found_version *version,
 		 void *const reloc_addr);
 auto void __attribute__((always_inline))
+elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
+			  void *const reloc_addr);
+# endif
+# if ! ELF_MACHINE_NO_RELA
+auto void __attribute__((always_inline))
 elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
 		  const ElfW(Sym) *sym, const struct r_found_version *version,
 		  void *const reloc_addr);
 auto void __attribute__((always_inline))
-elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
-			  void *const reloc_addr);
-auto void __attribute__((always_inline))
 elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
 			   void *const reloc_addr);
+# endif
 # if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
 auto void __attribute__((always_inline))
 elf_machine_lazy_rel (struct link_map *map,
diff -Naur glibc-2.3-20050314.orig/iconvdata/jis0208.h glibc-2.3-20050314/iconvdata/jis0208.h
--- glibc-2.3-20050314.orig/iconvdata/jis0208.h	2003-06-11 21:40:42.000000000 +0000
+++ glibc-2.3-20050314/iconvdata/jis0208.h	2005-03-28 22:58:06.000000000 +0000
@@ -1,5 +1,5 @@
 /* Access functions for JISX0208 conversion.
-   Copyright (C) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,1999,2000,2003,2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -24,15 +24,6 @@
 #include <gconv.h>
 #include <stdint.h>
 
-/* Conversion table.  */
-extern const uint16_t __jis0208_to_ucs[];
-
-extern const char __jisx0208_from_ucs4_lat1[256][2];
-extern const char __jisx0208_from_ucs4_greek[0xc1][2];
-extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[];
-extern const char __jisx0208_from_ucs_tab[][2];
-
-
 /* Struct for table with indeces in UCS mapping table.  */
 struct jisx0208_ucs_idx
 {
@@ -42,6 +33,15 @@
 };
 
 
+/* Conversion table.  */
+extern const uint16_t __jis0208_to_ucs[];
+
+extern const char __jisx0208_from_ucs4_lat1[256][2];
+extern const char __jisx0208_from_ucs4_greek[0xc1][2];
+extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[];
+extern const char __jisx0208_from_ucs_tab[][2];
+
+
 static inline uint32_t
 __attribute ((always_inline))
 jisx0208_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
diff -Naur glibc-2.3-20050314.orig/include/libc-symbols.h glibc-2.3-20050314/include/libc-symbols.h
--- glibc-2.3-20050314.orig/include/libc-symbols.h	2004-10-24 21:17:08.000000000 +0000
+++ glibc-2.3-20050314/include/libc-symbols.h	2005-03-28 22:57:45.000000000 +0000
@@ -582,78 +582,23 @@
 #  define hidden_proto(name, attrs...) \
   __hidden_proto (name, __GI_##name, ##attrs)
 #  define __hidden_proto(name, internal, attrs...) \
-  extern __typeof (name) internal; \
   extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
   __hidden_proto_hiddenattr (attrs);
 #  define __hidden_asmname(name) \
   __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
 #  define __hidden_asmname2(prefix, name) #prefix name
-#  ifdef HAVE_ASM_SET_DIRECTIVE
-#   define __hidden_def1(original, alias)			\
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
-  .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
-#   ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#     define __hidden_dot_def1(original, alias)	 ASM_LINE_SEP	\
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
-  .set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
-#   else
-#     define __hidden_dot_def1(original, alias)
-#   endif
-#  else
-#   define __hidden_def1(original, alias)			\
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP	\
-  C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-#   ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#    define __hidden_dot_def1(original, alias)	ASM_LINE_SEP	\
-  ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
-  C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
-#   else
-#    define __hidden_dot_def1(original, alias)
-#   endif
-#  endif
-#  define __hidden_def2(...) #__VA_ARGS__
-#  define __hidden_def3(...) __hidden_def2 (__VA_ARGS__)
-#  define hidden_def(name)					\
-  __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name) \
-  __hidden_dot_def1 (__GI_##name, name)));
-#  define hidden_data_def(name)					\
-  __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name)));
-#  define hidden_ver(local, name)				\
-  __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name) \
-  __hidden_dot_def1 (local, __GI_##name)));
-#  define hidden_data_ver(local, name)				\
-  __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name)));
-#  ifdef HAVE_WEAK_SYMBOLS
-#   ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-#    define __hidden_weak1(original, alias)			\
-  .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
-#    ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#     define __hidden_dot_weak1(original, alias)	ASM_LINE_SEP	\
-  .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
-#    else
-#     define __hidden_dot_weak1(original, alias)
-#    endif
-#   else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
-#    define __hidden_weak1(original, alias)			\
-  .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP			\
-  C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-#    ifdef HAVE_ASM_GLOBAL_DOT_NAME
-#     define __hidden_dot_weak1(original, alias)	ASM_LINE_SEP	\
-  .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP	\
-  C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
-#    else
-#     define __hidden_dot_weak1(original, alias)
-#    endif
-#   endif
-#   define hidden_weak(name)					\
-  __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name) \
-  __hidden_dot_weak1 (__GI_##name, name)));
-#   define hidden_data_weak(name)					\
-  __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name)));
-#  else
-#   define hidden_weak(name) hidden_def (name)
-#  endif
+#  define __hidden_ver1(local, internal, name) \
+  extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
+  extern __typeof (name) __EI_##name \
+	__attribute__((alias (__hidden_asmname (#local))))
+#  define hidden_ver(local, name)	__hidden_ver1(local, __GI_##name, name);
+#  define hidden_data_ver(local, name)	hidden_ver(local, name)
+#  define hidden_def(name)		__hidden_ver1(__GI_##name, name, name);
+#  define hidden_data_def(name)		hidden_def(name)
+#  define hidden_weak(name) \
+	__hidden_ver1(__GI_##name, name, name) __attribute__((weak));
+#  define hidden_data_weak(name)	hidden_weak(name)
 # else
 /* For assembly, we need to do the opposite of what we do in C:
    in assembly gcc __REDIRECT stuff is not in place, so functions
diff -Naur glibc-2.3-20050314.orig/include/wchar.h glibc-2.3-20050314/include/wchar.h
--- glibc-2.3-20050314.orig/include/wchar.h	2004-03-14 20:45:10.000000000 +0000
+++ glibc-2.3-20050314/include/wchar.h	2005-03-28 22:57:45.000000000 +0000
@@ -56,7 +56,6 @@
 extern int __wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
 			  size_t __n)
      __attribute_pure__;
-extern int __wcscoll (__const wchar_t *__s1, __const wchar_t *__s2);
 extern size_t __wcslen (__const wchar_t *__s) __attribute_pure__;
 extern size_t __wcsnlen (__const wchar_t *__s, size_t __maxlen)
      __attribute_pure__;
diff -Naur glibc-2.3-20050314.orig/string/strcoll.c glibc-2.3-20050314/string/strcoll.c
--- glibc-2.3-20050314.orig/string/strcoll.c	2004-03-14 20:51:30.000000000 +0000
+++ glibc-2.3-20050314/string/strcoll.c	2005-03-28 22:57:45.000000000 +0000
@@ -23,6 +23,7 @@
 # define STRING_TYPE char
 # define STRCOLL strcoll
 # define STRCOLL_L __strcoll_l
+# define USE_HIDDEN_DEF
 #endif
 
 #include "../locale/localeinfo.h"
@@ -35,6 +36,7 @@
 {
   return STRCOLL_L (s1, s2, _NL_CURRENT_LOCALE);
 }
-#if !defined WIDE_CHAR_VERSION
-libc_hidden_def (strcoll)
+
+#ifdef USE_HIDDEN_DEF
+libc_hidden_def (STRCOLL)
 #endif
diff -Naur glibc-2.3-20050314.orig/sysdeps/i386/dl-machine.h glibc-2.3-20050314/sysdeps/i386/dl-machine.h
--- glibc-2.3-20050314.orig/sysdeps/i386/dl-machine.h	2005-02-16 10:58:03.000000000 +0000
+++ glibc-2.3-20050314/sysdeps/i386/dl-machine.h	2005-03-28 22:58:14.000000000 +0000
@@ -387,13 +387,11 @@
 
 #endif /* !dl_machine_h */
 
-#ifdef RESOLVE
-
 /* The i386 never uses Elf32_Rela relocations for the dynamic linker.
    Prelinked libraries may use Elf32_Rela though.  */
-#ifdef RTLD_BOOTSTRAP
-# define ELF_MACHINE_NO_RELA 1
-#endif
+#define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
+
+#ifdef RESOLVE
 
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
    MAP is the object containing the reloc.  */
diff -Naur glibc-2.3-20050314.orig/wcsmbs/wcscoll.c glibc-2.3-20050314/wcsmbs/wcscoll.c
--- glibc-2.3-20050314.orig/wcsmbs/wcscoll.c	2004-03-14 21:05:48.000000000 +0000
+++ glibc-2.3-20050314/wcsmbs/wcscoll.c	2005-03-28 22:57:45.000000000 +0000
@@ -22,12 +22,11 @@
 
 #define STRING_TYPE wchar_t
 #define USTRING_TYPE wint_t
-#define STRCOLL __wcscoll
+#define STRCOLL wcscoll
 #define STRCOLL_L __wcscoll_l
 
 #include "../string/strcoll.c"
 
 #ifndef USE_IN_EXTENDED_LOCALE_MODEL
-weak_alias (__wcscoll, wcscoll)
 libc_hidden_weak (wcscoll)
 #endif
