* A patch for the unversioned lookup
@ 2001-05-03 15:34 H . J . Lu
2001-05-03 20:27 ` Ulrich Drepper
0 siblings, 1 reply; 8+ messages in thread
From: H . J . Lu @ 2001-05-03 15:34 UTC (permalink / raw)
To: GNU C Library; +Cc: Ulrich Drepper
[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]
While working on the atexit related problem, I noticed 2 problems
with the unversioned lookup:
1. The version index starts at 2 not 3. That is we should check
ndx > 1, not ndx > 2, for version names.
2. We should allow the hidden definition if there is no default
definition as long as there is only one definition.
I am also enclosing a testcase here.
H.J.
----
2001-05-03 H.J. Lu <hjl@gnu.org>
* do-lookup.h (FCT): Fix the unversioned lookup against the
nono-default version definition.
--- libc/elf/do-lookup.h.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/do-lookup.h Thu May 3 14:49:24 2001
@@ -125,11 +125,10 @@ FCT (const char *undef_name, unsigned lo
if (verstab != NULL)
{
ElfW(Half) ndx = verstab[symidx] & 0x7fff;
- if (ndx > 2) /* map->l_versions[ndx].hash != 0) */
+ if (ndx > 1) /* map->l_versions[ndx].hash != 0) */
{
- /* Don't accept hidden symbols. */
- if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
+ if (num_versions++ == 0)
+ /* Only one version so far. */
versioned_sym = sym;
continue;
}
Reply-To:
[-- Attachment #2: version15.tar.gz --]
[-- Type: application/x-gzip, Size: 726 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-03 15:34 A patch for the unversioned lookup H . J . Lu
@ 2001-05-03 20:27 ` Ulrich Drepper
2001-05-03 20:39 ` H . J . Lu
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Drepper @ 2001-05-03 20:27 UTC (permalink / raw)
To: H . J . Lu; +Cc: GNU C Library
"H . J . Lu" <hjl@lucon.org> writes:
> While working on the atexit related problem, I noticed 2 problems
> with the unversioned lookup:
I will not even look at this unless you provide examples.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-03 20:27 ` Ulrich Drepper
@ 2001-05-03 20:39 ` H . J . Lu
2001-05-03 23:13 ` H . J . Lu
0 siblings, 1 reply; 8+ messages in thread
From: H . J . Lu @ 2001-05-03 20:39 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Thu, May 03, 2001 at 08:27:46PM -0700, Ulrich Drepper wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
>
> > While working on the atexit related problem, I noticed 2 problems
> > with the unversioned lookup:
>
> I will not even look at this unless you provide examples.
>
I enclosed a testcase in
http://sources.redhat.com/ml/libc-alpha/2001-05/msg00021.html
The current glibc does
# make
cc -c -o foo.o foo.c
cc -fPIC -c b.c
cc -shared -o lib-b.so b.o
cc -fPIC -c c0.c
cc -Wl,-soname,lib-c.so -shared -o lib-c0.so c0.o
cp lib-c0.so lib-c.so
cc -o foo -Wl,-rpath,. foo.o lib-b.so lib-c.so
cc -fPIC -c c1.c
cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c1.so c1.o
cc -fPIC -c c2.c
cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c2.so c2.o
./foo
bar
cp lib-c1.so lib-c.so
./foo
bar
cp lib-c2.so lib-c.so
./foo
bar
The last one should fail since
# objdump --dynamic-sym lib-c.so | grep bar
000000000000086c g DF .text 000000000000002a Base _old_bar_1
0000000000000840 g DF .text 000000000000002a Base _old_bar
000000000000086c g DF .text 000000000000002a (VERS.1) bar
0000000000000840 g DF .text 000000000000002a (VERS.0) bar
There are 2 versions of bar, but none of them is default. With my
patch, I got
# /export/build/gnu/glibc/elf/ld-linux.so.2 ./foo
./foo: error while loading shared libraries: ./lib-b.so: undefined symbol: bar
Let me know if you have trouble getting my testcase.
Thanks.
H.J.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-03 20:39 ` H . J . Lu
@ 2001-05-03 23:13 ` H . J . Lu
2001-05-04 0:36 ` H . J . Lu
2001-05-04 9:18 ` H . J . Lu
0 siblings, 2 replies; 8+ messages in thread
From: H . J . Lu @ 2001-05-03 23:13 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Thu, May 03, 2001 at 08:39:40PM -0700, H . J . Lu wrote:
> On Thu, May 03, 2001 at 08:27:46PM -0700, Ulrich Drepper wrote:
> > "H . J . Lu" <hjl@lucon.org> writes:
> >
> > > While working on the atexit related problem, I noticed 2 problems
> > > with the unversioned lookup:
> >
> > I will not even look at this unless you provide examples.
> >
>
> I enclosed a testcase in
>
> http://sources.redhat.com/ml/libc-alpha/2001-05/msg00021.html
>
> The current glibc does
>
> # make
> cc -c -o foo.o foo.c
> cc -fPIC -c b.c
> cc -shared -o lib-b.so b.o
> cc -fPIC -c c0.c
> cc -Wl,-soname,lib-c.so -shared -o lib-c0.so c0.o
> cp lib-c0.so lib-c.so
> cc -o foo -Wl,-rpath,. foo.o lib-b.so lib-c.so
> cc -fPIC -c c1.c
> cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c1.so c1.o
> cc -fPIC -c c2.c
> cc -Wl,-soname,lib-c.so -Wl,--version-script=c.map -shared -o lib-c2.so c2.o
> ./foo
> bar
> cp lib-c1.so lib-c.so
> ./foo
> bar
> cp lib-c2.so lib-c.so
> ./foo
> bar
>
> The last one should fail since
>
> # objdump --dynamic-sym lib-c.so | grep bar
> 000000000000086c g DF .text 000000000000002a Base _old_bar_1
> 0000000000000840 g DF .text 000000000000002a Base _old_bar
> 000000000000086c g DF .text 000000000000002a (VERS.1) bar
> 0000000000000840 g DF .text 000000000000002a (VERS.0) bar
>
> There are 2 versions of bar, but none of them is default. With my
> patch, I got
>
> # /export/build/gnu/glibc/elf/ld-linux.so.2 ./foo
> ./foo: error while loading shared libraries: ./lib-b.so: undefined symbol: bar
>
> Let me know if you have trouble getting my testcase.
>
> Thanks.
>
>
That is incorrect. Here is a new one. I will send a patch for a new
testcase in glibc.
H.J.
----
2001-05-03 H.J. Lu <hjl@gnu.org>
* do-lookup.h (FCT): Fix the unversioned lookup against the
nono-default version definition.
--- libc/elf/do-lookup.h.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/do-lookup.h Thu May 3 23:06:37 2001
@@ -125,13 +125,21 @@ FCT (const char *undef_name, unsigned lo
if (verstab != NULL)
{
ElfW(Half) ndx = verstab[symidx] & 0x7fff;
- if (ndx > 2) /* map->l_versions[ndx].hash != 0) */
+ if (ndx > 1) /* map->l_versions[ndx].hash != 0) */
{
- /* Don't accept hidden symbols. */
- if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
- versioned_sym = sym;
- continue;
+ if ((verstab[symidx] & 0x8000) == 0)
+ {
+ /* We found the default version. */
+ goto found_it;
+ }
+ else
+ {
+ /* We found a hidden symbol. Only one version is
+ allowed. */
+ if (num_versions++ == 0)
+ versioned_sym = sym;
+ continue;
+ }
}
}
#endif
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-03 23:13 ` H . J . Lu
@ 2001-05-04 0:36 ` H . J . Lu
2001-05-04 9:18 ` H . J . Lu
1 sibling, 0 replies; 8+ messages in thread
From: H . J . Lu @ 2001-05-04 0:36 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Thu, May 03, 2001 at 11:14:02PM -0700, H . J . Lu wrote:
>
> That is incorrect. Here is a new one. I will send a patch for a new
> testcase in glibc.
>
Here is the testcase for glibc.
H.J.
---
2001-05-04 H.J. Lu <hjl@gnu.org>
* elf/Makefile (distribute): Add tst-version.sh, version.map,
versionobj0.c, versionobj1.c and versionobj2.c.
(test-srcs): Add tst-version.
(modules-names): Add versionobj1 and versionobj2.
(tests): Also depend on $(objpfx)tst-version.out.
$(objpfx)%.so: Also filter out versionobj1 and versionobj2.
($(objpfx)versionobj0a.so): New target.
($(objpfx)versionobj0b.so): New target.
($(objpfx)versionobj1.so): New target.
($(objpfx)versionobj2.so): New target.
($(objpfx)versionobj.so): New target.
($(objpfx)tst-version): New target.
($(objpfx)tst-version.out): New target.
* elf/tst-version.c: New file.
* elf/tst-version.sh: New file.
* elf/version.map: New file.
* elf/versionobj0.c: New file.
* elf/versionobj1.c: New file.
* elf/versionobj2.c: New file.
--- libc/elf/Makefile.version Sat Mar 24 21:04:33 2001
+++ libc/elf/Makefile Fri May 4 00:23:43 2001
@@ -57,7 +57,9 @@ distribute := $(rtld-routines:=.c) dynam
neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
neededobj5.c neededobj6.c firstobj.c \
unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
- testobj.h vismod.h globalmod1.c
+ testobj.h vismod.h globalmod1.c \
+ tst-version.sh version.map versionobj0.c \
+ versionobj1.c versionobj2.c
include ../Makeconfig
@@ -102,7 +104,7 @@ tests = loadtest restest1 preloadtest lo
reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \
$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
neededtest3 neededtest4 unload2 lateglobal initfirst global
-test-srcs = tst-pathopt
+test-srcs = tst-pathopt tst-version
tests-vis-yes = vismain
tests-nodelete-yes = nodelete
tests-nodlopen-yes = nodlopen
@@ -115,7 +117,8 @@ modules-names = testobj1 testobj2 testob
reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
neededobj1 neededobj2 neededobj3 neededobj4 \
neededobj5 neededobj6 firstobj globalmod1 \
- unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj
+ unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
+ versionobj1 versionobj2
modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
modules-nodlopen-yes = nodlopenmod
@@ -247,7 +250,7 @@ generated += $(addsuffix .so,$(strip $(m
ifeq (yes,$(build-shared))
ifeq ($(cross-compiling),no)
-tests: $(objpfx)tst-pathopt.out
+tests: $(objpfx)tst-pathopt.out $(objpfx)tst-version.out
endif
endif
@@ -276,7 +279,10 @@ $(objpfx)firstobj.so: $(shared-thread-li
$(objpfx)globalmod1.so: $(libdl)
# filtmod1.so has a special rule
-$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
+$(filter-out $(objpfx)filtmod1.so \
+ $(objpfx)versionobj1.so \
+ $(objpfx)versionobj2.so, \
+ $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
$(build-module)
$(objpfx)loadtest: $(libdl)
@@ -369,6 +375,41 @@ $(objpfx)filtmod1.so: $(objpfx)filtmod1.
-Wl,-rpath-link=$(rpath-link) \
$< -Wl,-F,$(objpfx)filtmod2.so
$(objpfx)filter: $(objpfx)filtmod1.so
+
+$(objpfx)versionobj0a.so: $(objpfx)versionobj0.os
+ $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+ -L$(subst :, -L,$(rpath-link)) \
+ -Wl,-rpath-link=$(rpath-link) $<
+
+$(objpfx)versionobj0b.so: $(objpfx)versionobj0.os
+ $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+ -L$(subst :, -L,$(rpath-link)) \
+ -Wl,-rpath-link=$(rpath-link) $< \
+ -Wl,--version-script=version.map
+
+$(objpfx)versionobj1.so: $(objpfx)versionobj1.os
+ $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+ -L$(subst :, -L,$(rpath-link)) \
+ -Wl,-rpath-link=$(rpath-link) $< \
+ -Wl,--version-script=version.map
+
+$(objpfx)versionobj2.so: $(objpfx)versionobj2.os
+ $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
+ -L$(subst :, -L,$(rpath-link)) \
+ -Wl,-rpath-link=$(rpath-link) $< \
+ -Wl,--version-script=version.map
+
+$(objpfx)tst-version: $(objpfx)versionobj.so
+$(objpfx)versionobj.so: $(objpfx)versionobj0a.so
+ rm -f $@
+ ln -s $(<F) $@
+
+$(objpfx)tst-version.out: tst-version.sh $(objpfx)tst-version \
+ $(objpfx)versionobj0a.so \
+ $(objpfx)versionobj0b.so \
+ $(objpfx)versionobj1.so \
+ $(objpfx)versionobj2.so
+ $(SHELL) $< $(common-objpfx) > $@
$(objpfx)unload: $(libdl)
$(objpfx)unload.out: $(objpfx)unloadmod.so
--- libc/elf/tst-version.c.version Thu May 3 23:40:15 2001
+++ libc/elf/tst-version.c Thu May 3 23:36:48 2001
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+
+extern int bar (void);
+extern int foo;
+
+int
+main(int argc, char **argv)
+{
+ int result = 0;
+
+ if (argc > 1)
+ result = atoi (argv [1]);
+
+ if (bar () != result || foo != result)
+ result = 1;
+ else
+ result = 0;
+
+ return result;
+}
--- libc/elf/tst-version.sh.version Thu May 3 23:27:01 2001
+++ libc/elf/tst-version.sh Fri May 4 00:27:06 2001
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Test versioned symbol lookup.
+# Copyright (C) 2001 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
+# modify it under the terms of the GNU Library General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB. If
+# not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+common_objpfx=$1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj0a.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+ ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 0
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj0b.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+ ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 0
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj1.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+ ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 1
+test $? = 0 || exit 1
+
+rm -f ${common_objpfx}elf/versionobj.so
+ln -s versionobj2.so ${common_objpfx}elf/versionobj.so
+LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}. \
+ ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-version 2
+test $? = 0 && rm -f ${common_objpfx}elf/versionobj.so && exit 1
+rm -f ${common_objpfx}elf/versionobj.so
+
+exit 0
--- libc/elf/version.map.version Thu May 3 23:40:02 2001
+++ libc/elf/version.map Thu May 3 23:40:33 2001
@@ -0,0 +1,11 @@
+VERS.0 {
+ global:
+ bar;
+ foo;
+};
+
+VERS.1 {
+ global:
+ bar;
+ foo;
+} VERS.0;
--- libc/elf/versionobj0.c.version Thu May 3 23:42:15 2001
+++ libc/elf/versionobj0.c Thu May 3 23:41:44 2001
@@ -0,0 +1,7 @@
+int foo = 0;
+
+int
+bar (void)
+{
+ return foo;
+}
--- libc/elf/versionobj1.c.version Thu May 3 23:42:18 2001
+++ libc/elf/versionobj1.c Thu May 3 23:41:57 2001
@@ -0,0 +1,10 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 1;
+
+int
+_old_bar (void)
+{
+ return _old_foo;
+}
--- libc/elf/versionobj2.c.version Thu May 3 23:42:31 2001
+++ libc/elf/versionobj2.c Thu May 3 23:42:05 2001
@@ -0,0 +1,20 @@
+__asm__(".symver _old_bar,bar@VERS.0");
+__asm__(".symver _old_foo,foo@VERS.0");
+
+int _old_foo = 2;
+
+int
+_old_bar (void)
+{
+ return _old_foo;
+}
+
+__asm__(".symver _old_bar_1,bar@VERS.1");
+__asm__(".symver _old_foo_1,foo@VERS.1");
+
+int _old_foo_1 = 2;
+int
+_old_bar_1 (void)
+{
+ return _old_foo_1;
+}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-03 23:13 ` H . J . Lu
2001-05-04 0:36 ` H . J . Lu
@ 2001-05-04 9:18 ` H . J . Lu
2001-05-09 16:04 ` H . J . Lu
1 sibling, 1 reply; 8+ messages in thread
From: H . J . Lu @ 2001-05-04 9:18 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Thu, May 03, 2001 at 11:14:02PM -0700, H . J . Lu wrote:
> >
>
> That is incorrect. Here is a new one. I will send a patch for a new
> testcase in glibc.
>
>
Here is an update. I modified do_lookup to return version name and
print it out if asked. It is useful to know which vesion of an
unversioned symbol is bound to.
H.J.
----
2001-05-04 H.J. Lu <hjl@gnu.org>
* elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
do_lookup and print it out if asked.
(_dl_lookup_symbol_skip): Likewise.
* do-lookup.h (do_lookup): Return version name. Fix the
unversioned lookup against the nono-default version definition.
--- libc/elf/dl-lookup.c.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/dl-lookup.c Fri May 4 09:10:30 2001
@@ -197,13 +197,14 @@ _dl_lookup_symbol (const char *undef_nam
int protected;
int noexec = elf_machine_lookup_noexec_p (reloc_type);
int noplt = elf_machine_lookup_noplt_p (reloc_type);
+ const char *version_name = NULL;
++_dl_num_relocations;
/* Search the relevant loaded objects for a definition. */
for (scope = symbol_scope; *scope; ++scope)
- if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0, NULL,
- noexec, noplt))
+ if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
+ &version_name, NULL, noexec, noplt))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
@@ -242,12 +243,13 @@ _dl_lookup_symbol (const char *undef_nam
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -262,7 +264,7 @@ _dl_lookup_symbol (const char *undef_nam
for (scope = symbol_scope; *scope; ++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- NULL, 0, 1))
+ &version_name, NULL, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
@@ -294,6 +296,7 @@ _dl_lookup_symbol_skip (const char *unde
struct r_scope_elem **scope;
size_t i;
int protected;
+ const char *version_name = NULL;
++_dl_num_relocations;
@@ -304,10 +307,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| ! do_lookup (undef_name, hash, *ref, ¤t_value, *scope, i,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
break;
if (__builtin_expect (current_value.s == NULL, 0))
@@ -319,12 +322,13 @@ _dl_lookup_symbol_skip (const char *unde
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -339,10 +343,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| !do_lookup (undef_name, hash, *ref, &protected_value, *scope, i,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
--- libc/elf/do-lookup.h.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/do-lookup.h Fri May 4 09:05:52 2001
@@ -22,7 +22,7 @@
# define ARG const struct r_found_version *const version,
#else
# define FCT do_lookup
-# define ARG
+# define ARG const char **version_name,
#endif
/* Inner part of the lookup functions. We return a value > 0 if we
@@ -125,13 +125,25 @@ FCT (const char *undef_name, unsigned lo
if (verstab != NULL)
{
ElfW(Half) ndx = verstab[symidx] & 0x7fff;
- if (ndx > 2) /* map->l_versions[ndx].hash != 0) */
+ if (ndx > 1) /* map->l_versions[ndx].hash != 0) */
{
- /* Don't accept hidden symbols. */
- if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
- versioned_sym = sym;
- continue;
+ if ((verstab[symidx] & 0x8000) == 0)
+ {
+ /* We found the default version. */
+ *version_name = map->l_versions[ndx].name;
+ goto found_it;
+ }
+ else
+ {
+ /* We found a hidden symbol. Only one version is
+ allowed. */
+ if (num_versions++ == 0)
+ {
+ versioned_sym = sym;
+ *version_name = map->l_versions[ndx].name;
+ }
+ continue;
+ }
}
}
#endif
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-04 9:18 ` H . J . Lu
@ 2001-05-09 16:04 ` H . J . Lu
2001-05-09 17:42 ` H . J . Lu
0 siblings, 1 reply; 8+ messages in thread
From: H . J . Lu @ 2001-05-09 16:04 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Fri, May 04, 2001 at 09:18:23AM -0700, H . J . Lu wrote:
> On Thu, May 03, 2001 at 11:14:02PM -0700, H . J . Lu wrote:
> > >
> >
> > That is incorrect. Here is a new one. I will send a patch for a new
> > testcase in glibc.
> >
> >
>
> Here is an update. I modified do_lookup to return version name and
> print it out if asked. It is useful to know which vesion of an
> unversioned symbol is bound to.
>
> H.J.
> ----
> 2001-05-04 H.J. Lu <hjl@gnu.org>
>
> * elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
> do_lookup and print it out if asked.
> (_dl_lookup_symbol_skip): Likewise.
>
> * do-lookup.h (do_lookup): Return version name. Fix the
> unversioned lookup against the nono-default version definition.
>
This patch is wrong. I will fix it.
H.J.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A patch for the unversioned lookup
2001-05-09 16:04 ` H . J . Lu
@ 2001-05-09 17:42 ` H . J . Lu
0 siblings, 0 replies; 8+ messages in thread
From: H . J . Lu @ 2001-05-09 17:42 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: GNU C Library
On Wed, May 09, 2001 at 04:04:03PM -0700, H . J . Lu wrote:
> On Fri, May 04, 2001 at 09:18:23AM -0700, H . J . Lu wrote:
> > On Thu, May 03, 2001 at 11:14:02PM -0700, H . J . Lu wrote:
> > > >
> > >
> > > That is incorrect. Here is a new one. I will send a patch for a new
> > > testcase in glibc.
> > >
> > >
> >
> > Here is an update. I modified do_lookup to return version name and
> > print it out if asked. It is useful to know which vesion of an
> > unversioned symbol is bound to.
> >
> > H.J.
> > ----
> > 2001-05-04 H.J. Lu <hjl@gnu.org>
> >
> > * elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
> > do_lookup and print it out if asked.
> > (_dl_lookup_symbol_skip): Likewise.
> >
> > * do-lookup.h (do_lookup): Return version name. Fix the
> > unversioned lookup against the nono-default version definition.
> >
>
> This patch is wrong. I will fix it.
>
>
The current glibc is ok. I was wrong. This patch doesn't fix any bug.
But it may help debug code.
H.J.
----
2001-05-03 H.J. Lu <hjl@gnu.org>
* elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
do_lookup and print it out if asked.
(_dl_lookup_symbol_skip): Likewise.
* do-lookup.h (do_lookup): Return version name.
--- libc/elf/dl-lookup.c.version Wed May 9 16:22:07 2001
+++ libc/elf/dl-lookup.c Wed May 9 16:23:03 2001
@@ -197,13 +197,14 @@ _dl_lookup_symbol (const char *undef_nam
int protected;
int noexec = elf_machine_lookup_noexec_p (reloc_type);
int noplt = elf_machine_lookup_noplt_p (reloc_type);
+ const char *version_name = NULL;
++_dl_num_relocations;
/* Search the relevant loaded objects for a definition. */
for (scope = symbol_scope; *scope; ++scope)
- if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0, NULL,
- noexec, noplt))
+ if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
+ &version_name, NULL, noexec, noplt))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
@@ -242,12 +243,13 @@ _dl_lookup_symbol (const char *undef_nam
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -262,7 +264,7 @@ _dl_lookup_symbol (const char *undef_nam
for (scope = symbol_scope; *scope; ++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- NULL, 0, 1))
+ &version_name, NULL, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
@@ -294,6 +296,7 @@ _dl_lookup_symbol_skip (const char *unde
struct r_scope_elem **scope;
size_t i;
int protected;
+ const char *version_name = NULL;
++_dl_num_relocations;
@@ -304,10 +307,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| ! do_lookup (undef_name, hash, *ref, ¤t_value, *scope, i,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
break;
if (__builtin_expect (current_value.s == NULL, 0))
@@ -319,12 +322,13 @@ _dl_lookup_symbol_skip (const char *unde
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -339,10 +343,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| !do_lookup (undef_name, hash, *ref, &protected_value, *scope, i,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
--- libc/elf/do-lookup.h.version Wed May 9 16:22:07 2001
+++ libc/elf/do-lookup.h Wed May 9 16:37:45 2001
@@ -22,7 +22,7 @@
# define ARG const struct r_found_version *const version,
#else
# define FCT do_lookup
-# define ARG
+# define ARG const char **version_name,
#endif
/* Inner part of the lookup functions. We return a value > 0 if we
@@ -129,10 +129,14 @@ FCT (const char *undef_name, unsigned lo
{
/* Don't accept hidden symbols. */
if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
- versioned_sym = sym;
+ {
+ /* No version so far. */
+ *version_name = map->l_versions[ndx].name;
+ versioned_sym = sym;
+ }
continue;
}
+ *version_name = map->l_versions[ndx].name;
}
#endif
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-05-09 17:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-03 15:34 A patch for the unversioned lookup H . J . Lu
2001-05-03 20:27 ` Ulrich Drepper
2001-05-03 20:39 ` H . J . Lu
2001-05-03 23:13 ` H . J . Lu
2001-05-04 0:36 ` H . J . Lu
2001-05-04 9:18 ` H . J . Lu
2001-05-09 16:04 ` H . J . Lu
2001-05-09 17:42 ` H . J . Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).