Remove the getpagesize system call from ia64
H . J . Lu
hjl@valinux.com
Wed Jan 10 23:55:00 GMT 2001
On Wed, Jan 10, 2001 at 11:07:49PM -0800, Ulrich Drepper wrote:
> "H . J . Lu" <hjl@valinux.com> writes:
>
> > #ifdef DL_STATIC_INIT
> > DL_STATIC_INIT (map)
> > #endif
>
> OK with me but
>
Here is the patch.
H.J.
---
2001-01-10 H.J. Lu <hjl@gnu.org>
* elf/dl-libc.c (do_dlopen): Call DL_STATIC_INIT for static
binaries.
* sysdeps/ia64/Makefile (sysdep-dl-routines): Add dl-static.
* sysdeps/ia64/Versions (ld): Add _dl_var_init.
* sysdeps/ia64/dl-lookupcfg.h (_dl_static_init): Declared.
(DL_STATIC_INIT): Defined.
* sysdeps/generic/ldsodefs.h (DL_STATIC_INIT): Defined if not
defined.
* sysdeps/ia64/dl-static.c: New file.
Index: elf/dl-libc.c
===================================================================
RCS file: /work/cvs/gnu/glibc/elf/dl-libc.c,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 dl-libc.c
--- elf/dl-libc.c 2000/08/31 16:48:13 1.1.1.7
+++ elf/dl-libc.c 2001/01/11 07:07:17
@@ -76,6 +76,10 @@ do_dlopen (void *ptr)
struct do_dlopen_args *args = (struct do_dlopen_args *) ptr;
/* Open and relocate the shared object. */
args->map = _dl_open (args->name, RTLD_LAZY, NULL);
+
+#ifndef SHARED
+ DL_STATIC_INIT (args->map);
+#endif
}
static void
Index: sysdeps/ia64/Makefile
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/ia64/Makefile,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 Makefile
--- sysdeps/ia64/Makefile 2000/11/28 19:57:17 1.1.1.5
+++ sysdeps/ia64/Makefile 2001/01/11 06:46:26
@@ -10,7 +10,7 @@ CPPFLAGS-start.S = -D__ASSEMBLY__
endif
ifeq ($(subdir),elf)
-sysdep-dl-routines += dl-symaddr dl-fptr
+sysdep-dl-routines += dl-symaddr dl-fptr dl-static
sysdep_routines += $(sysdep-dl-routines)
sysdep-rtld-routines += $(sysdep-dl-routines)
endif
Index: sysdeps/ia64/Versions
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/ia64/Versions,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 Versions
--- sysdeps/ia64/Versions 2000/11/16 18:49:34 1.1.1.3
+++ sysdeps/ia64/Versions 2001/01/11 06:56:39
@@ -2,6 +2,6 @@ ld {
GLIBC_2.2 {
# ia64 specific functions in the dynamic linker, but used by libc.so.
_dl_symbol_address; _dl_unmap; _dl_lookup_address;
- _dl_function_address;
+ _dl_function_address; _dl_var_init;
}
}
Index: sysdeps/ia64/dl-lookupcfg.h
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/ia64/dl-lookupcfg.h,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 dl-lookupcfg.h
--- sysdeps/ia64/dl-lookupcfg.h 2000/11/16 18:49:34 1.1.1.4
+++ sysdeps/ia64/dl-lookupcfg.h 2001/01/11 06:56:19
@@ -42,3 +42,6 @@ extern Elf64_Addr _dl_function_address (
#define DL_FUNCTION_ADDRESS(map, addr) _dl_function_address (map, addr)
#define DL_DT_INIT_ADDRESS(map, addr) DL_FUNCTION_ADDRESS (map, addr)
#define DL_DT_FINI_ADDRESS(map, addr) DL_FUNCTION_ADDRESS (map, addr)
+
+extern void _dl_static_init (struct link_map *map);
+#define DL_STATIC_INIT(map) _dl_static_init (map)
Index: sysdeps/generic/ldsodefs.h
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/generic/ldsodefs.h,v
retrieving revision 1.1.1.14
diff -u -p -r1.1.1.14 ldsodefs.h
--- sysdeps/generic/ldsodefs.h 2000/12/31 19:35:20 1.1.1.14
+++ sysdeps/generic/ldsodefs.h 2001/01/11 07:01:38
@@ -81,6 +81,10 @@ typedef ElfW(Addr) lookup_t;
(map)->l_map_end - (map)->l_map_start)
#endif
+#ifndef DL_STATIC_INIT
+#define DL_STATIC_INIT(map)
+#endif
+
/* For the version handling we need an array with only names and their
hash values. */
struct r_found_version
--- /dev/null Thu Aug 24 02:00:32 2000
+++ sysdeps/ia64/dl-static.c Wed Jan 10 23:50:47 2001
@@ -0,0 +1,77 @@
+/* Variable initialization. IA-64 version.
+ Copyright (C) 2001 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <ldsodefs.h>
+
+extern int _dl_clktck;
+
+#ifdef SHARED
+
+void
+_dl_var_init (void *array [])
+{
+ /* It has to match "variables" below. */
+ enum
+ {
+ DL_PAGESIZE = 0,
+ DL_CLKTCK
+ };
+
+ _dl_pagesize = *((size_t *) array [DL_PAGESIZE]);
+ _dl_clktck = *((int *) array [DL_CLKTCK]);
+}
+
+#else
+#include <bits/libc-lock.h>
+
+__libc_lock_define_initialized_recursive (, _dl_static_lock)
+
+static void *variables [] =
+{
+ &_dl_pagesize,
+ &_dl_clktck
+};
+
+void
+_dl_static_init (struct link_map *map)
+{
+ const ElfW(Sym) *ref;
+ lookup_t loadbase;
+ void (*f) (void *[]);
+ static int done = 0;
+
+ __libc_lock_lock (_dl_static_lock);
+
+ if (done)
+ {
+ __libc_lock_unlock (_dl_static_lock);
+ return;
+ }
+
+ done = 1;
+
+ loadbase = _dl_lookup_symbol ("_dl_var_init", map, &ref,
+ map->l_local_scope, 0, 1);
+ f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
+ f (variables);
+
+ __libc_lock_unlock (_dl_static_lock);
+}
+
+#endif
More information about the Libc-alpha
mailing list