mirror of git://sourceware.org/git/glibc.git
Handle DSOs without any dependency in ld.so
This commit is contained in:
parent
4997db7429
commit
6b1e7d1992
|
|
@ -1,5 +1,11 @@
|
||||||
2011-05-30 Ulrich Drepper <drepper@gmail.com>
|
2011-05-30 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
[BZ #12454]
|
||||||
|
* elf/dl-deps.c (_dl_map_object_deps): Run initializer sorting only
|
||||||
|
when there are multiple maps.
|
||||||
|
* elf/dl-fini.c (_dl_sort_fini): Check for list of one.
|
||||||
|
(_dl_fini): Remove test here.
|
||||||
|
|
||||||
* elf/rtld.c (dl_main): Don't allow the loader to load itself.
|
* elf/rtld.c (dl_main): Don't allow the loader to load itself.
|
||||||
|
|
||||||
2011-05-29 Ulrich Drepper <drepper@gmail.com>
|
2011-05-29 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
|
||||||
4
NEWS
4
NEWS
|
|
@ -1,4 +1,4 @@
|
||||||
GNU C Library NEWS -- history of user-visible changes. 2011-5-29
|
GNU C Library NEWS -- history of user-visible changes. 2011-5-30
|
||||||
Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
|
Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
See the end for copying conditions.
|
See the end for copying conditions.
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ Version 2.14
|
||||||
* The RPC implementation in libc is obsoleted. Old programs keep working
|
* The RPC implementation in libc is obsoleted. Old programs keep working
|
||||||
but new programs cannot be linked with the routines in libc anymore.
|
but new programs cannot be linked with the routines in libc anymore.
|
||||||
Programs in need of RPC functionality must be linked against TI-RPC.
|
Programs in need of RPC functionality must be linked against TI-RPC.
|
||||||
The TI-RPC implemtation is IPv6 enabled and there are other benefits.
|
The TI-RPC implementation is IPv6 enabled and there are other benefits.
|
||||||
|
|
||||||
Visible changes of this change include (obviously) the inability to link
|
Visible changes of this change include (obviously) the inability to link
|
||||||
programs using RPC functions without referencing the TI-RPC library and the
|
programs using RPC functions without referencing the TI-RPC library and the
|
||||||
|
|
|
||||||
|
|
@ -617,61 +617,64 @@ Filters not supported with LD_TRACE_PRELINKING"));
|
||||||
map->l_searchlist.r_list[i]->l_reserved = 0;
|
map->l_searchlist.r_list[i]->l_reserved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now determine the order in which the initialization has to happen. */
|
/* Sort the initializer list to take dependencies into account. The binary
|
||||||
|
itself will always be initialize last. */
|
||||||
memcpy (l_initfini, map->l_searchlist.r_list,
|
memcpy (l_initfini, map->l_searchlist.r_list,
|
||||||
nlist * sizeof (struct link_map *));
|
nlist * sizeof (struct link_map *));
|
||||||
|
if (__builtin_expect (nlist > 1, 1))
|
||||||
/* We can skip looking for the binary itself which is at the front
|
|
||||||
of the search list. */
|
|
||||||
assert (nlist > 1);
|
|
||||||
i = 1;
|
|
||||||
bool seen[nlist];
|
|
||||||
memset (seen, false, nlist * sizeof (seen[0]));
|
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
/* Keep track of which object we looked at this round. */
|
/* We can skip looking for the binary itself which is at the front
|
||||||
seen[i] = true;
|
of the search list. */
|
||||||
struct link_map *thisp = l_initfini[i];
|
i = 1;
|
||||||
|
bool seen[nlist];
|
||||||
/* Find the last object in the list for which the current one is
|
memset (seen, false, nlist * sizeof (seen[0]));
|
||||||
a dependency and move the current object behind the object
|
while (1)
|
||||||
with the dependency. */
|
|
||||||
unsigned int k = nlist - 1;
|
|
||||||
while (k > i)
|
|
||||||
{
|
{
|
||||||
struct link_map **runp = l_initfini[k]->l_initfini;
|
/* Keep track of which object we looked at this round. */
|
||||||
if (runp != NULL)
|
seen[i] = true;
|
||||||
/* Look through the dependencies of the object. */
|
struct link_map *thisp = l_initfini[i];
|
||||||
while (*runp != NULL)
|
|
||||||
if (__builtin_expect (*runp++ == thisp, 0))
|
|
||||||
{
|
|
||||||
/* Move the current object to the back past the last
|
|
||||||
object with it as the dependency. */
|
|
||||||
memmove (&l_initfini[i], &l_initfini[i + 1],
|
|
||||||
(k - i) * sizeof (l_initfini[0]));
|
|
||||||
l_initfini[k] = thisp;
|
|
||||||
|
|
||||||
if (seen[i + 1])
|
/* Find the last object in the list for which the current one is
|
||||||
|
a dependency and move the current object behind the object
|
||||||
|
with the dependency. */
|
||||||
|
unsigned int k = nlist - 1;
|
||||||
|
while (k > i)
|
||||||
|
{
|
||||||
|
struct link_map **runp = l_initfini[k]->l_initfini;
|
||||||
|
if (runp != NULL)
|
||||||
|
/* Look through the dependencies of the object. */
|
||||||
|
while (*runp != NULL)
|
||||||
|
if (__builtin_expect (*runp++ == thisp, 0))
|
||||||
{
|
{
|
||||||
++i;
|
/* Move the current object to the back past the last
|
||||||
goto next_clear;
|
object with it as the dependency. */
|
||||||
|
memmove (&l_initfini[i], &l_initfini[i + 1],
|
||||||
|
(k - i) * sizeof (l_initfini[0]));
|
||||||
|
l_initfini[k] = thisp;
|
||||||
|
|
||||||
|
if (seen[i + 1])
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
goto next_clear;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (&seen[i], &seen[i + 1],
|
||||||
|
(k - i) * sizeof (seen[0]));
|
||||||
|
seen[k] = true;
|
||||||
|
|
||||||
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove (&seen[i], &seen[i + 1], (k - i) * sizeof (seen[0]));
|
--k;
|
||||||
seen[k] = true;
|
}
|
||||||
|
|
||||||
goto next;
|
if (++i == nlist)
|
||||||
}
|
break;
|
||||||
|
next_clear:
|
||||||
|
memset (&seen[i], false, (nlist - i) * sizeof (seen[0]));
|
||||||
|
|
||||||
--k;
|
next:;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++i == nlist)
|
|
||||||
break;
|
|
||||||
next_clear:
|
|
||||||
memset (&seen[i], false, (nlist - i) * sizeof (seen[0]));
|
|
||||||
|
|
||||||
next:;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the list of dependencies. */
|
/* Terminate the list of dependencies. */
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,12 @@ internal_function
|
||||||
_dl_sort_fini (struct link_map *l, struct link_map **maps, size_t nmaps,
|
_dl_sort_fini (struct link_map *l, struct link_map **maps, size_t nmaps,
|
||||||
char *used, Lmid_t ns)
|
char *used, Lmid_t ns)
|
||||||
{
|
{
|
||||||
|
/* A list of one element need not be sorted. */
|
||||||
|
if (nmaps == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
/* We can skip looking for the binary itself which is at the front
|
/* We can skip looking for the binary itself which is at the front
|
||||||
of the search list for the main namespace. */
|
of the search list for the main namespace. */
|
||||||
assert (nmaps > 1);
|
|
||||||
unsigned int i = ns == LM_ID_BASE;
|
unsigned int i = ns == LM_ID_BASE;
|
||||||
bool seen[nmaps];
|
bool seen[nmaps];
|
||||||
memset (seen, false, nmaps * sizeof (seen[0]));
|
memset (seen, false, nmaps * sizeof (seen[0]));
|
||||||
|
|
@ -195,9 +198,8 @@ _dl_fini (void)
|
||||||
assert (ns == LM_ID_BASE || i == nloaded || i == nloaded - 1);
|
assert (ns == LM_ID_BASE || i == nloaded || i == nloaded - 1);
|
||||||
nmaps = i;
|
nmaps = i;
|
||||||
|
|
||||||
if (nmaps > 1)
|
/* Now we have to do the sorting. */
|
||||||
/* Now we have to do the sorting. */
|
_dl_sort_fini (GL(dl_ns)[ns]._ns_loaded, maps, nmaps, NULL, ns);
|
||||||
_dl_sort_fini (GL(dl_ns)[ns]._ns_loaded, maps, nmaps, NULL, ns);
|
|
||||||
|
|
||||||
/* We do not rely on the linked list of loaded object anymore from
|
/* We do not rely on the linked list of loaded object anymore from
|
||||||
this point on. We have our own list here (maps). The various
|
this point on. We have our own list here (maps). The various
|
||||||
|
|
|
||||||
|
|
@ -922,7 +922,6 @@ dl_main (const ElfW(Phdr) *phdr,
|
||||||
|
|
||||||
/* Process the environment variable which control the behaviour. */
|
/* Process the environment variable which control the behaviour. */
|
||||||
process_envvars (&mode);
|
process_envvars (&mode);
|
||||||
mode=trace;
|
|
||||||
|
|
||||||
#ifndef HAVE_INLINED_SYSCALLS
|
#ifndef HAVE_INLINED_SYSCALLS
|
||||||
/* Set up a flag which tells we are just starting. */
|
/* Set up a flag which tells we are just starting. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue