This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
PATCH: Optimize protected symbol lookup
- From: "H. J. Lu" <hjl at lucon dot org>
- To: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Tue, 25 Mar 2003 10:33:52 -0800
- Subject: PATCH: Optimize protected symbol lookup
This patch avoids looking up protected symbols twice.
H.J.
---
2003-03-25 H.J. Lu <hjl at gnu dot org>
* elf/dl-lookup.c (_dl_lookup_symbol): Avoid looking up
protected symbols twice.
(_dl_lookup_versioned_symbol): Likewise.
--- elf/dl-lookup.c.vsb 2003-01-11 23:58:41.000000000 -0800
+++ elf/dl-lookup.c 2003-03-25 10:17:51.000000000 -0800
@@ -273,17 +273,30 @@ _dl_lookup_symbol (const char *undef_nam
{
/* It is very tricky. We need to figure out what value to
return for the protected symbol. */
- struct sym_val protected_value = { NULL, NULL };
-
- for (scope = symbol_scope; *scope; ++scope)
- if (_dl_do_lookup (undef_name, hash, *ref, &protected_value, *scope,
- 0, flags, NULL, ELF_RTYPE_CLASS_PLT))
- break;
-
- if (protected_value.s != NULL && protected_value.m != undef_map)
+ if (type_class == ELF_RTYPE_CLASS_PLT)
{
- current_value.s = *ref;
- current_value.m = undef_map;
+ if (current_value.s != NULL && current_value.m != undef_map)
+ {
+ current_value.s = *ref;
+ current_value.m = undef_map;
+ }
+ }
+ else
+ {
+ struct sym_val protected_value = { NULL, NULL };
+
+ for (scope = symbol_scope; *scope; ++scope)
+ if (_dl_do_lookup (undef_name, hash, *ref,
+ &protected_value, *scope, 0, flags,
+ NULL, ELF_RTYPE_CLASS_PLT))
+ break;
+
+ if (protected_value.s != NULL
+ && protected_value.m != undef_map)
+ {
+ current_value.s = *ref;
+ current_value.m = undef_map;
+ }
}
}
@@ -465,18 +478,31 @@ _dl_lookup_versioned_symbol (const char
{
/* It is very tricky. We need to figure out what value to
return for the protected symbol. */
- struct sym_val protected_value = { NULL, NULL };
-
- for (scope = symbol_scope; *scope; ++scope)
- if (_dl_do_lookup_versioned (undef_name, hash, *ref, &protected_value,
- *scope, 0, version, NULL,
- ELF_RTYPE_CLASS_PLT))
- break;
-
- if (protected_value.s != NULL && protected_value.m != undef_map)
+ if (type_class == ELF_RTYPE_CLASS_PLT)
{
- current_value.s = *ref;
- current_value.m = undef_map;
+ if (current_value.s != NULL && current_value.m != undef_map)
+ {
+ current_value.s = *ref;
+ current_value.m = undef_map;
+ }
+ }
+ else
+ {
+ struct sym_val protected_value = { NULL, NULL };
+
+ for (scope = symbol_scope; *scope; ++scope)
+ if (_dl_do_lookup_versioned (undef_name, hash, *ref,
+ &protected_value,
+ *scope, 0, version, NULL,
+ ELF_RTYPE_CLASS_PLT))
+ break;
+
+ if (protected_value.s != NULL
+ && protected_value.m != undef_map)
+ {
+ current_value.s = *ref;
+ current_value.m = undef_map;
+ }
}
}