Remove the getpagesize system call from ia64
H . J . Lu
hjl@valinux.com
Thu Jan 11 11:26:00 GMT 2001
On Thu, Jan 11, 2001 at 09:55:08AM -0800, Ulrich Drepper wrote:
>
> This code makes the assumption that the first loaded object (or at
> least the first for which the function is called) is ld.so. There is
> no such guarantee.
I don't think it will happen very often since libc.so will always bring
in ld.so. If you don't build a DSO with -lc, I doubt you can dlopen it
from a static binary unless you don't make any calls to libc. I don't
think we should support building a DSO without -lc. It will also lead
to other problems. But it is always nice to check it.
>
> Therefore setting of done should be postponed until it is clear the
> object is ld.so and the result of _dl_lookup_symbol should be checked
> for an error. If the function returns with an error the object is not
> ld.so and no function call must be made and done must not be set.
>
> Another possible problem is that ld.so can be unloaded. The variable
> would have to be reset. I don't think done is necessary at all.
>
Agreed. Here is a patch. Also I moved DL_STATIC_INIT to _dl_open.
Otherwise, dlopen in a static binary won't work.
--
H.J. Lu (hjl@valinux.com)
-----
2001-01-11 H.J. Lu <hjl@gnu.org>
* elf/dl-libc.c (do_dlopen): Move DL_STATIC_INIT to ...
* elf/dl-open.c (_dl_open): Here.
* sysdeps/unix/sysv/linux/ia64/dl-static.c (_dl_static_lock):
Make it static.
(_dl_static_init): Initialize the variables every time when
possible.
* sysdeps/unix/sysv/linux/ia64/ldsodefs.h (DL_STATIC_INIT):
Undefine it first.
Index: elf/dl-libc.c
===================================================================
RCS file: /work/cvs/gnu/glibc/elf/dl-libc.c,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 dl-libc.c
--- elf/dl-libc.c 2001/01/11 18:31:03 1.1.1.8
+++ elf/dl-libc.c 2001/01/11 18:49:00
@@ -76,10 +76,6 @@ 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: elf/dl-open.c
===================================================================
RCS file: /work/cvs/gnu/glibc/elf/dl-open.c,v
retrieving revision 1.1.1.13
diff -u -p -r1.1.1.13 dl-open.c
--- elf/dl-open.c 2000/12/31 19:34:12 1.1.1.13
+++ elf/dl-open.c 2001/01/11 18:49:08
@@ -430,6 +430,10 @@ _dl_open (const char *file, int mode, co
_dl_signal_error (errcode, objname, local_errstring);
}
+#ifndef SHARED
+ DL_STATIC_INIT (args.map);
+#endif
+
return args.map;
}
Index: sysdeps/unix/sysv/linux/ia64/dl-static.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/ia64/dl-static.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 dl-static.c
--- sysdeps/unix/sysv/linux/ia64/dl-static.c 2001/01/11 18:32:42 1.1.1.1
+++ sysdeps/unix/sysv/linux/ia64/dl-static.c 2001/01/11 19:22:48
@@ -40,7 +40,7 @@ _dl_var_init (void *array[])
#else
#include <bits/libc-lock.h>
-__libc_lock_define_initialized_recursive (, _dl_static_lock)
+__libc_lock_define_initialized_recursive (static, _dl_static_lock)
static void *variables[] =
{
@@ -54,22 +54,16 @@ _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);
+ if (ref != NULL)
+ {
+ f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
+ f (variables);
+ }
__libc_lock_unlock (_dl_static_lock);
}
Index: sysdeps/unix/sysv/linux/ia64/ldsodefs.h
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/ia64/ldsodefs.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 ldsodefs.h
--- sysdeps/unix/sysv/linux/ia64/ldsodefs.h 2001/01/11 18:32:42 1.1.1.1
+++ sysdeps/unix/sysv/linux/ia64/ldsodefs.h 2001/01/11 18:53:48
@@ -27,6 +27,7 @@
/* We need special support to initialize DSO loaded for statically linked
binaries. */
extern void _dl_static_init (struct link_map *map);
+#undef DL_STATIC_INIT
#define DL_STATIC_INIT(map) _dl_static_init (map)
#endif /* ldsodefs.h */
More information about the Libc-alpha
mailing list