summaryrefslogtreecommitdiff
path: root/elf/dl-object.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-12-15 12:32:27 -0800
committerUlrich Drepper <drepper@redhat.com>2009-12-15 12:32:27 -0800
commit2af6396817fb9df98e63de75dd59fd999ee9f1d0 (patch)
treed66827c66d770f1f3d697dbb027b59064e6ab0e0 /elf/dl-object.c
parent2510d01ddba195f8cfaa3c2349f75e0612719d82 (diff)
Avoid ELF lookup race.
On some architectures the update of the l_used field in the lookup functions races with setting the other bits in the bitfield. Simply avoid this and optimize use of l_used in general.
Diffstat (limited to 'elf/dl-object.c')
-rw-r--r--elf/dl-object.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/elf/dl-object.c b/elf/dl-object.c
index be4ea38f9f..788e2c07b9 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -1,5 +1,5 @@
/* Storage management for the chain of loaded shared objects.
- Copyright (C) 1995-2002,2004,2006,2007,2008 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002,2004,2006-2008,2009 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
@@ -67,6 +67,10 @@ _dl_new_object (char *realname, const char *libname, int type,
new->l_name = realname;
new->l_type = type;
+ /* If we set the bit now since we know it is never used we avoid
+ dirtying the cache line later. */
+ if ((GLRO(dl_debug_mask) & DL_DEBUG_UNUSED) == 0)
+ new->l_used = 1;
new->l_loader = loader;
#if NO_TLS_OFFSET != 0
new->l_tls_offset = NO_TLS_OFFSET;
@@ -174,7 +178,7 @@ _dl_new_object (char *realname, const char *libname, int type,
if (result == NULL)
{
/* We were not able to determine the current directory.
- Note that free(origin) is OK if origin == NULL. */
+ Note that free(origin) is OK if origin == NULL. */
free (origin);
origin = (char *) -1;
goto out;