# DP: Description: i386 ld.so gets sigsegv when i686 optimized library is used, # because the structure size of rtld_global and rtld_global_ro # are different due to HP_TIMING_AVAIL availability. # This patch aligns those sizes for using i686 optimized library. # DP: Author: Daniel Jacobowitz # DP: Upstream status: Pending # DP: Status Details: # DP: Date: 2003-10-03 (Updated 2003-10-12), (Updated 2005-01-02, 2005-03-03 gotom) 2005-03-03 GOTO Masanori * sysdeps/generic/ldsodefs.h (struct rtld_global, rtld_global_ro): Include timing members if HP_TIMING_PAD is defined. 2005-01-02 GOTO Masanori * elf/Makefile: Regenerate. 2003-12-31 Jeff Bailey * sysdeps/sparc/hp-timing.h: New file. 2003-10-12 Daniel Jacobowitz * sysdeps/generic/ldsodefs.h (struct rtld_global): Include timing members if HP_TIMING_PAD is defined. * sysdeps/i386/hp-timing.h: New file. * elf/Makefile: Add dl-altinit to routines, shared-only-routines. * elf/dl-altinit.c: New file. --- glibc-2.3.4/sysdeps/generic/ldsodefs.h.gotom 2005-03-03 11:23:08 +0900 +++ glibc-2.3.4/sysdeps/generic/ldsodefs.h 2005-03-03 11:24:05 +0900 @@ -258,7 +258,7 @@ /* The object to be initialized first. */ EXTERN struct link_map *_dl_initfirst; -#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL +#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL || HP_TIMING_PAD /* Start time on CPU clock. */ EXTERN hp_timing_t _dl_cpuclock_offset; #endif @@ -462,7 +462,7 @@ /* All search directories defined at startup. */ EXTERN struct r_search_path_elem *_dl_init_all_dirs; -#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL +#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL || HP_TIMING_PAD /* Overhead of a high-precision timing measurement. */ EXTERN hp_timing_t _dl_hp_timing_overhead; #endif --- /dev/null 1969-12-31 19:00:00 -0500 +++ glibc-2.3.2/sysdeps/i386/hp-timing.h 2003-10-03 11:50:30 -0400 @@ -0,0 +1,34 @@ +/* High precision, low overhead timing functions. i386 version. + Copyright (C) 2003 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _i386_HP_TIMING_H +#define _i386_HP_TIMING_H 1 + +#define hp_timing_t hp_timing_t__ +#include +#undef hp_timing_t + +/* We don't use high-precision timers, but we might load an i686 libpthread + which does. */ +#define HP_TIMING_PAD 1 + +/* i686 uses 64bit values for the times. */ +typedef unsigned long long int hp_timing_t; + +#endif /* hp-timing.h */ --- /dev/null 1969-12-31 19:00:00 -0500 +++ glibc-2.3.2/sysdeps/sparc/sparc32/hp-timing.h 2003-10-03 11:50:30 -0400 @@ -0,0 +1,34 @@ +/* High precision, low overhead timing functions. i386 version. + Copyright (C) 2003 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SPARC_HP_TIMING_H +#define _SPARC_HP_TIMING_H 1 + +#define hp_timing_t hp_timing_t__ +#include +#undef hp_timing_t + +/* We don't use high-precision timers, but we might load an sparcv9 libpthread + which does. */ +#define HP_TIMING_PAD 1 + +/* sparcv9 uses 64bit values for the times. */ +typedef unsigned long long int hp_timing_t; + +#endif /* hp-timing.h */ --- /dev/null 1969-12-31 19:00:00 -0500 +++ glibc-2.3.2/elf/dl-altinit.c 2003-10-12 13:23:15 -0400 @@ -0,0 +1,43 @@ +/* Extra initializers for shared libc. + Copyright (C) 2003 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +/* This file is used from the shared libc, to initialize anything which + ld.so should have initialized but didn't - for instance, if ld.so + is built for a machine without HP_TIMING but libc.so is built for + a machine with HP_TIMING, clock_gettime will expect dl_cpuclock_offset + to be initialized. */ + +static void +dlinit_hptiming (void) +{ +#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL + if (GL(dl_cpuclock_offset) == 0) + HP_TIMING_NOW (GL(dl_cpuclock_offset)); +#endif +} + +static void dlinit_alt (void) __attribute__((constructor)); +static void +dlinit_alt (void) +{ + dlinit_hptiming (); +} --- glibc-2.3.4/elf/Makefile 27 Oct 2004 20:26:47 -0000 1.287 +++ glibc-2.3.4/elf/Makefile 2 Jan 2005 08:29:55 -0000 @@ -23,7 +23,7 @@ headers = elf.h bits/elfclass.h link.h routines = $(dl-routines) dl-open dl-close dl-support dl-iteratephdr \ dl-addr enbl-secure dl-profstub \ - dl-origin dl-libc dl-sym dl-tsd + dl-origin dl-libc dl-sym dl-tsd dl-altinit # The core dynamic linking functions are in libc for the static and # profiled libraries. @@ -41,6 +41,10 @@ rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines) +# We only need to re-run initializers if ld.so and libc.so might be built +# for different machines, so only shared libraries need dl-altinit. +shared-only-routines = dl-altinit + distribute := rtld-Rules \ $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \ dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \