mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* elf/dl-open.c (add_to_global): Introduce variable ns to help gcc
optimize. Complerely extend global scope array before making the new entries visible.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2007-05-11 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-open.c (add_to_global): Introduce variable ns to help gcc
|
||||||
|
optimize. Complerely extend global scope array before making the
|
||||||
|
new entries visible.
|
||||||
|
|
||||||
2007-05-10 Ulrich Drepper <drepper@redhat.com>
|
2007-05-10 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/tst-getcpu.c: New file.
|
* sysdeps/unix/sysv/linux/tst-getcpu.c: New file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Load a shared object at runtime, relocate it, and run its initializer.
|
/* Load a shared object at runtime, relocate it, and run its initializer.
|
||||||
Copyright (C) 1996-2004, 2005, 2006 Free Software Foundation, Inc.
|
Copyright (C) 1996-2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -97,17 +97,17 @@ add_to_global (struct link_map *new)
|
|||||||
in an realloc() call. Therefore we allocate a completely new
|
in an realloc() call. Therefore we allocate a completely new
|
||||||
array the first time we have to add something to the locale scope. */
|
array the first time we have to add something to the locale scope. */
|
||||||
|
|
||||||
if (GL(dl_ns)[new->l_ns]._ns_global_scope_alloc == 0)
|
struct link_namespaces *ns = &GL(dl_ns)[new->l_ns];
|
||||||
|
if (ns->_ns_global_scope_alloc == 0)
|
||||||
{
|
{
|
||||||
/* This is the first dynamic object given global scope. */
|
/* This is the first dynamic object given global scope. */
|
||||||
GL(dl_ns)[new->l_ns]._ns_global_scope_alloc
|
ns->_ns_global_scope_alloc
|
||||||
= GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist + to_add + 8;
|
= ns->_ns_main_searchlist->r_nlist + to_add + 8;
|
||||||
new_global = (struct link_map **)
|
new_global = (struct link_map **)
|
||||||
malloc (GL(dl_ns)[new->l_ns]._ns_global_scope_alloc
|
malloc (ns->_ns_global_scope_alloc * sizeof (struct link_map *));
|
||||||
* sizeof (struct link_map *));
|
|
||||||
if (new_global == NULL)
|
if (new_global == NULL)
|
||||||
{
|
{
|
||||||
GL(dl_ns)[new->l_ns]._ns_global_scope_alloc = 0;
|
ns->_ns_global_scope_alloc = 0;
|
||||||
nomem:
|
nomem:
|
||||||
_dl_signal_error (ENOMEM, new->l_libname->name, NULL,
|
_dl_signal_error (ENOMEM, new->l_libname->name, NULL,
|
||||||
N_("cannot extend global scope"));
|
N_("cannot extend global scope"));
|
||||||
@ -115,29 +115,29 @@ add_to_global (struct link_map *new)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy over the old entries. */
|
/* Copy over the old entries. */
|
||||||
GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list
|
ns->_ns_main_searchlist->r_list
|
||||||
= memcpy (new_global,
|
= memcpy (new_global, ns->_ns_main_searchlist->r_list,
|
||||||
GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list,
|
(ns->_ns_main_searchlist->r_nlist
|
||||||
(GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist
|
|
||||||
* sizeof (struct link_map *)));
|
* sizeof (struct link_map *)));
|
||||||
}
|
}
|
||||||
else if (GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist + to_add
|
else if (ns->_ns_main_searchlist->r_nlist + to_add
|
||||||
> GL(dl_ns)[new->l_ns]._ns_global_scope_alloc)
|
> ns->_ns_global_scope_alloc)
|
||||||
{
|
{
|
||||||
/* We have to extend the existing array of link maps in the
|
/* We have to extend the existing array of link maps in the
|
||||||
main map. */
|
main map. */
|
||||||
new_global = (struct link_map **)
|
new_global = (struct link_map **)
|
||||||
realloc (GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list,
|
realloc (ns->_ns_main_searchlist->r_list,
|
||||||
((GL(dl_ns)[new->l_ns]._ns_global_scope_alloc + to_add + 8)
|
((ns->_ns_global_scope_alloc + to_add + 8)
|
||||||
* sizeof (struct link_map *)));
|
* sizeof (struct link_map *)));
|
||||||
if (new_global == NULL)
|
if (new_global == NULL)
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
GL(dl_ns)[new->l_ns]._ns_global_scope_alloc += to_add + 8;
|
ns->_ns_global_scope_alloc += to_add + 8;
|
||||||
GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list = new_global;
|
ns->_ns_main_searchlist->r_list = new_global;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now add the new entries. */
|
/* Now add the new entries. */
|
||||||
|
unsigned int added = 0;
|
||||||
for (cnt = 0; cnt < new->l_searchlist.r_nlist; ++cnt)
|
for (cnt = 0; cnt < new->l_searchlist.r_nlist; ++cnt)
|
||||||
{
|
{
|
||||||
struct link_map *map = new->l_searchlist.r_list[cnt];
|
struct link_map *map = new->l_searchlist.r_list[cnt];
|
||||||
@ -145,11 +145,14 @@ add_to_global (struct link_map *new)
|
|||||||
if (map->l_global == 0)
|
if (map->l_global == 0)
|
||||||
{
|
{
|
||||||
map->l_global = 1;
|
map->l_global = 1;
|
||||||
GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_list[GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist]
|
ns->_ns_main_searchlist->r_list[ns->_ns_main_searchlist->r_nlist
|
||||||
|
+ added]
|
||||||
= map;
|
= map;
|
||||||
++GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist;
|
++added;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
atomic_write_barrier ();
|
||||||
|
ns->_ns_main_searchlist->r_nlist += added;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user