* [PATCH] Fix build with GCC 4
@ 2005-03-05 9:21 Jakub Jelinek
2005-03-05 14:30 ` Andreas Schwab
2005-03-06 21:23 ` Roland McGrath
0 siblings, 2 replies; 4+ messages in thread
From: Jakub Jelinek @ 2005-03-05 9:21 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
The thread_offsetof change just mirrors what Alan Modra did to NPTL
tcb-offsets.sym. Apparently for GCC 4 an offsetof like expression,
but not really offsetof, is no longer constant folded and therefore
not suitable for "i" constraint.
The ELF_MACHINE_NO_RELA change is needed to avoid
rtld.c: In function '_dl_start':
dynamic-link.h:50: error: nested function 'elf_machine_rela_relative' declared but never defined
dynamic-link.h:47: error: nested function 'elf_machine_rela' declared but never defined
This is what happens.
rtld.c first includes dl-machine.h without RESOLVE_MAP
and without RTLD_BOOTSTRAP defined. This means that ELF_MACHINE_NO_RELA
is not defined on i386/arm. Later on it defines RESOLVE_MAP
and RTLD_BOOTSTRAP and includes dynamic-link.h which has:
# 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_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
void *const reloc_addr);
# endif
and later on includes dl-machine.h which sees RTLD_BOOTSTRAP is
defined and defines ELF_MACHINE_NO_RELA and doesn't define
elf_machine_rela* nested functions.
But the prototypes were already defined and GCC 4 doesn't like this.
ELF_MACHINE_NO_RELA is only ever used in preprocessing conditionals
and never in defined ELF_MACHINE_NO_RELA, so the trick below
already defines ELF_MACHINE_NO_RELA to 1/0 depending on whether
RTLD_BOOTSTRAP is defined and thus the prototypes in dynamic-link.h
that are not desirable are gone.
2005-03-05 Jakub Jelinek <jakub@redhat.com>
* sysdeps/i386/dl-machine.h (ELF_MACHINE_NO_RELA): Define
unconditionally to (defined RTLD_BOOTSTRAP).
* sysdeps/arm/dl-machine.h (ELF_MACHINE_NO_RELA): Likewise.
linuxthreads/
* sysdeps/powerpc/tcb-offsets.sym (thread_offsetof): Rework for GCC 4.
--- libc/linuxthreads/sysdeps/powerpc/tcb-offsets.sym.jj 2005-03-04 14:21:29.000000000 -0500
+++ libc/linuxthreads/sysdeps/powerpc/tcb-offsets.sym 2005-03-04 14:26:29.000000000 -0500
@@ -8,7 +8,7 @@
-- Abuse tls.h macros to derive offsets relative to the thread register.
# undef __thread_register
# define __thread_register ((void *) 0)
-# define thread_offsetof(mem) ((void *) &THREAD_SELF->p_##mem - (void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct _pthread_descr_struct, p_##mem))
# else
--- libc/sysdeps/i386/dl-machine.h.jj 2005-02-16 20:16:33.000000000 -0500
+++ libc/sysdeps/i386/dl-machine.h 2005-03-04 16:50:32.313591897 -0500
@@ -301,9 +301,7 @@ elf_machine_plt_value (struct link_map *
/* 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_MAP
--- libc/sysdeps/arm/dl-machine.h.jj 2005-03-01 15:34:40.000000000 -0500
+++ libc/sysdeps/arm/dl-machine.h 2005-03-04 16:50:43.913473979 -0500
@@ -353,9 +353,7 @@ elf_machine_plt_value (struct link_map *
/* ARM 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
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix build with GCC 4
2005-03-05 9:21 [PATCH] Fix build with GCC 4 Jakub Jelinek
@ 2005-03-05 14:30 ` Andreas Schwab
2005-03-05 14:53 ` Jakub Jelinek
2005-03-06 21:23 ` Roland McGrath
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2005-03-05 14:30 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Roland McGrath, Glibc hackers
Jakub Jelinek <jakub@redhat.com> writes:
> --- libc/sysdeps/i386/dl-machine.h.jj 2005-02-16 20:16:33.000000000 -0500
> +++ libc/sysdeps/i386/dl-machine.h 2005-03-04 16:50:32.313591897 -0500
> @@ -301,9 +301,7 @@ elf_machine_plt_value (struct link_map *
>
> /* 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)
Does gcc guarantee that this works (which would be an extension wrt the C
standard)?
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix build with GCC 4
2005-03-05 14:30 ` Andreas Schwab
@ 2005-03-05 14:53 ` Jakub Jelinek
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2005-03-05 14:53 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Ulrich Drepper, Roland McGrath, Glibc hackers
On Sat, Mar 05, 2005 at 03:30:00PM +0100, Andreas Schwab wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
>
> > --- libc/sysdeps/i386/dl-machine.h.jj 2005-02-16 20:16:33.000000000 -0500
> > +++ libc/sysdeps/i386/dl-machine.h 2005-03-04 16:50:32.313591897 -0500
> > @@ -301,9 +301,7 @@ elf_machine_plt_value (struct link_map *
> >
> > /* 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)
>
> Does gcc guarantee that this works (which would be an extension wrt the C
> standard)?
It certainly works with all GCC's I've tried: 2.96-RH, 3.2.3, 3.3.4, 3.4.3,
4.0 branch, HEAD.
And because this is an internal header, if it stops working in some future
compiler version, then we can change it.
FYI, glibc already uses this in _G_config.h:
$ find . -name \*.[chS] | xargs grep _G_HAVE_ST_BLKSIZE
./sysdeps/gnu/_G_config.h:#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
./sysdeps/generic/_G_config.h:#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
./sysdeps/mach/hurd/_G_config.h:#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
./libio/libio.h:#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
$ find . -name \*.[chS] | xargs grep _IO_HAVE_ST_BLKSIZE
./libio/wfiledoalloc.c:#if _IO_HAVE_ST_BLKSIZE
./libio/libio.h:#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
./libio/filedoalloc.c:#if _IO_HAVE_ST_BLKSIZE
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix build with GCC 4
2005-03-05 9:21 [PATCH] Fix build with GCC 4 Jakub Jelinek
2005-03-05 14:30 ` Andreas Schwab
@ 2005-03-06 21:23 ` Roland McGrath
1 sibling, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2005-03-06 21:23 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
I am not seeing these rtld.c errors.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-06 21:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-05 9:21 [PATCH] Fix build with GCC 4 Jakub Jelinek
2005-03-05 14:30 ` Andreas Schwab
2005-03-05 14:53 ` Jakub Jelinek
2005-03-06 21:23 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).