This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Another dlsym(RTLD_NEXT, ) problem(s)


Hi!

Attached are three testcases, test and test3 give different results on Linux
and Solaris.
At least test3 output with glibc is IMHO wrong.

Output on Linux is:
test
main
c: 0x8048474 0x40018790
e: 0x8048474 0x4015d780
a: 0x8048474 0x4015f790
d: 0x8048474 0x40163790
b: 0x8048474 (nil)
test2
main
g: 0x804847c 0x4015f790
a: 0x400187a0 0x40161790
b: 0x400187a0 0x40163790
c: 0x400187a0 0x40165790
d: 0x400187a0 0x40168790
f: 0x400187a0 (nil)
test3
main
i: 0x804847c 0x40168790
h: 0x804847c 0x4016a790
g: 0x804847c (nil)
and on Solaris:
test
main
c: 207c8 ff20053c
b: 207c8 0
test2
main
g: 207d0 ff320538
a: ff37054c ff30053c
b: ff37054c ff2e053c
c: ff37054c ff1e053c
d: ff37054c ff1c0538
f: ff37054c 0
test3
main
i: 207d0 ff1c053c
h: 207d0 ff1a053c
g: 207d0 ff180538
f: 207d0 0

The first test tests RTLD_NEXT behaviour with DT_AUXILIARY libraries where
`c' is the aux filter. Apparently, RTLD_NEXT in the aux filter goes into its
DT_NEEDED dependencies (this is the `c' -> `b' jump, later on it behaves the
same (ie. nothing comes after `b').

In the third test this is because of r_duplist. I actually cannot understand
why is r_duplist created at all and use and this is specifically example where it
causes different results.
Solaris man page is not entirely clear:
     In  the  case  of  the  special  handle  RTLD_NEXT,  dlsym()
     searches  for  the  named  symbol  in  the objects that were
     loaded following the object from which the dlsym()  call  is
     being made.
by my understanding of this is that RTLD_NEXT searches in the l_local_scope
of its ultimate l_loader starting with after the map, ie. IMHO
_dl_lookup_symbol_skip should look for the map in r_list, not r_duplist.
Finding an index in r_duplist and using that index into r_list cannot be
right, because from the way how r_duplist is created the same map can be
present at different positions in both lists.
In test3 case:
r_list		main e i libdl libc a b c d h ld g f
r_duplist	main e i libdl libc a b c d libc h libc libc ld libc a libc a libc a libc g libc f libc libc
so finding g in the duplist gives index above nlist (and if there were just
one further entry before h in duplist it would find RTLD_NEXT(h) -> f
instead of g) and the search continues in the next scope (but l_local_scope
has only one, so fails).

I'd like to understand these things for the prelinking work.

	Jakub

rtld_next.tar.bz2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]