patches/glibc/linuxthreads-2.3.4/glibc-linuxthreads-2.3.4-allow-gcc-4.0-rtld.patch
changeset 1 eeea35fbf182
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/linuxthreads-2.3.4/glibc-linuxthreads-2.3.4-allow-gcc-4.0-rtld.patch	Sat Feb 24 11:00:05 2007 +0000
     1.3 @@ -0,0 +1,89 @@
     1.4 +See http://sources.redhat.com/ml/libc-hacker/2005-03/msg00008.html
     1.5 +
     1.6 +From libc-hacker-return-8343-listarch-libc-hacker=sources dot redhat dot com at sources dot redhat dot com Sat Mar 05 09:21:18 2005
     1.7 +Return-Path: <libc-hacker-return-8343-listarch-libc-hacker=sources dot redhat dot com at sources dot redhat dot com>
     1.8 +Delivered-To: listarch-libc-hacker at sources dot redhat dot com
     1.9 +Received: (qmail 23370 invoked by alias); 5 Mar 2005 09:21:15 -0000
    1.10 +Mailing-List: contact libc-hacker-help at sources dot redhat dot com; run by ezmlm
    1.11 +Precedence: bulk
    1.12 +List-Subscribe: <mailto:libc-hacker-subscribe at sources dot redhat dot com>
    1.13 +List-Archive: <http://sources.redhat.com/ml/libc-hacker/>
    1.14 +List-Post: <mailto:libc-hacker at sources dot redhat dot com>
    1.15 +List-Help: <mailto:libc-hacker-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
    1.16 +Sender: libc-hacker-owner at sources dot redhat dot com
    1.17 +Delivered-To: mailing list libc-hacker at sources dot redhat dot com
    1.18 +Received: (qmail 22971 invoked from network); 5 Mar 2005 09:20:51 -0000
    1.19 +Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.15.26)
    1.20 +  by sourceware dot org with SMTP; 5 Mar 2005 09:20:51 -0000
    1.21 +Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1])
    1.22 +	by sunsite dot mff dot cuni dot cz (8 dot 13 dot 1/8 dot 13 dot 1) with ESMTP id j259KoB5020894;
    1.23 +	Sat, 5 Mar 2005 10:20:50 +0100
    1.24 +Received: (from jj@localhost)
    1.25 +	by sunsite dot mff dot cuni dot cz (8 dot 13 dot 1/8 dot 13 dot 1/Submit) id j259KnO1020889;
    1.26 +	Sat, 5 Mar 2005 10:20:49 +0100
    1.27 +Date: Sat, 5 Mar 2005 10:20:49 +0100
    1.28 +From: Jakub Jelinek <jakub at redhat dot com>
    1.29 +To: Ulrich Drepper <drepper at redhat dot com>, Roland McGrath <roland at redhat dot com>
    1.30 +Cc: Glibc hackers <libc-hacker at sources dot redhat dot com>
    1.31 +Subject: [PATCH] Fix build with GCC 4
    1.32 +Message-ID: <20050305092049.GJ4777@sunsite.mff.cuni.cz>
    1.33 +Reply-To: Jakub Jelinek <jakub at redhat dot com>
    1.34 +Mime-Version: 1.0
    1.35 +Content-Type: text/plain; charset=us-ascii
    1.36 +Content-Disposition: inline
    1.37 +User-Agent: Mutt/1.4.1i
    1.38 +
    1.39 +Hi!
    1.40 +
    1.41 +The thread_offsetof change just mirrors what Alan Modra did to NPTL
    1.42 +tcb-offsets.sym.  Apparently for GCC 4 an offsetof like expression,
    1.43 +but not really offsetof, is no longer constant folded and therefore
    1.44 +not suitable for "i" constraint.
    1.45 +
    1.46 +The ELF_MACHINE_NO_RELA change is needed to avoid
    1.47 +rtld.c: In function '_dl_start':
    1.48 +dynamic-link.h:50: error: nested function 'elf_machine_rela_relative' declared but never defined
    1.49 +dynamic-link.h:47: error: nested function 'elf_machine_rela' declared but never defined
    1.50 +This is what happens.
    1.51 +rtld.c first includes dl-machine.h without RESOLVE_MAP
    1.52 +and without RTLD_BOOTSTRAP defined.  This means that ELF_MACHINE_NO_RELA
    1.53 +is not defined on i386/arm.  Later on it defines RESOLVE_MAP
    1.54 +and RTLD_BOOTSTRAP and includes dynamic-link.h which has:
    1.55 +# if ! ELF_MACHINE_NO_RELA
    1.56 +auto void __attribute__((always_inline))
    1.57 +elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
    1.58 +                  const ElfW(Sym) *sym, const struct r_found_version *version,
    1.59 +                  void *const reloc_addr);
    1.60 +auto void __attribute__((always_inline))
    1.61 +elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
    1.62 +                           void *const reloc_addr);
    1.63 +# endif
    1.64 +and later on includes dl-machine.h which sees RTLD_BOOTSTRAP is
    1.65 +defined and defines ELF_MACHINE_NO_RELA and doesn't define
    1.66 +elf_machine_rela* nested functions.
    1.67 +But the prototypes were already defined and GCC 4 doesn't like this.
    1.68 +ELF_MACHINE_NO_RELA is only ever used in preprocessing conditionals
    1.69 +and never in defined ELF_MACHINE_NO_RELA, so the trick below
    1.70 +already defines ELF_MACHINE_NO_RELA to 1/0 depending on whether
    1.71 +RTLD_BOOTSTRAP is defined and thus the prototypes in dynamic-link.h
    1.72 +that are not desirable are gone.
    1.73 +
    1.74 +2005-03-05  Jakub Jelinek  <jakub@redhat.com>
    1.75 +
    1.76 +	* sysdeps/i386/dl-machine.h (ELF_MACHINE_NO_RELA): Define
    1.77 +	unconditionally to (defined RTLD_BOOTSTRAP).
    1.78 +	* sysdeps/arm/dl-machine.h (ELF_MACHINE_NO_RELA): Likewise.
    1.79 +linuxthreads/
    1.80 +	* sysdeps/powerpc/tcb-offsets.sym (thread_offsetof): Rework for GCC 4.
    1.81 +
    1.82 +--- libc/linuxthreads/sysdeps/powerpc/tcb-offsets.sym.jj	2005-03-04 14:21:29.000000000 -0500
    1.83 ++++ libc/linuxthreads/sysdeps/powerpc/tcb-offsets.sym	2005-03-04 14:26:29.000000000 -0500
    1.84 +@@ -8,7 +8,7 @@
    1.85 + -- Abuse tls.h macros to derive offsets relative to the thread register.
    1.86 + #  undef __thread_register
    1.87 + #  define __thread_register	((void *) 0)
    1.88 +-#  define thread_offsetof(mem)	((void *) &THREAD_SELF->p_##mem - (void *) 0)
    1.89 ++#  define thread_offsetof(mem)	((ptrdiff_t) THREAD_SELF + offsetof (struct _pthread_descr_struct, p_##mem))
    1.90 + 
    1.91 + # else
    1.92 +