[PATCH] Fix _dl_map_object

Jakub Jelinek jakub@redhat.com
Tue Mar 6 04:39:00 GMT 2001


Hi!

The l->l_opencount == 0 test in _dl_map_object is not very good in the new
reference counting model, since ld.so will open/read/fstat/close the same
library multiple times if it is being added more than once during the same
dlopen call (or during dl_main), because l_opencount is bumped after all
dependencies are loaded (e.g. if a program has DT_NEEDED libc.so.6 and
libfoo.so.0 and libfoo.so.0 has DT_NEEDED libc.so.6, then libc.so.6 will be
open_verify'ed twice and caught by the later _dl_map_object_from_fd st_ino +
st_dev check).
Looking at October 18'th code (right before reference counting changes),
l_opencount was bumped immediately after _dl_new_object, with the single
exception when creating the fake entry if the library is not found.
So, IMHO either the test should go away completely (if we'll take fake
entries as sufficient) or replaced with l_faked test (if ld.so should try
again to find that library). I've attached both alternatives.

	Jakub


More information about the Libc-hacker mailing list