This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: libc/2251: Weak undefined symbol doesn't work properly with PIE
- From: "H. J. Lu" <hjl at lucon dot org>
- To: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Tue, 31 Jan 2006 11:20:58 -0800
- Subject: PATCH: libc/2251: Weak undefined symbol doesn't work properly with PIE
The problem is ld.so looks up undefined hidden or internal symbol.
There is no need to do so in the first place.
H.J.
----
2006-01-31 H.J. Lu <hongjiu.lu@intel.com>
PR libc/2251
* elf/dl-lookup.c (_dl_lookup_symbol_x): Don't lookup hidden
or internal symbol.
--- elf/dl-lookup.c.pie 2006-01-03 14:01:28.000000000 -0800
+++ elf/dl-lookup.c 2006-01-31 10:43:07.000000000 -0800
@@ -216,6 +216,15 @@ _dl_lookup_symbol_x (const char *undef_n
up a versioned symbol. */
assert (version == NULL || flags == 0 || flags == DL_LOOKUP_ADD_DEPENDENCY);
+ int hidden = (*ref
+ && (ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_INTERNAL
+ || ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_HIDDEN));
+ if (__builtin_expect (hidden != 0, 0))
+ {
+ /* It is a hidden/internal symbol. We won't look elsewhere. */
+ goto not_found;
+ }
+
size_t i = 0;
if (__builtin_expect (skip_map != NULL, 0))
{
@@ -261,6 +270,7 @@ _dl_lookup_symbol_x (const char *undef_n
if (__builtin_expect (current_value.s == NULL, 0))
{
+not_found:
if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
&& skip_map == NULL)
{