public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* what is the dlopen criterion used to decide if library needs to be loaded?
@ 2020-11-13 21:24 Daniel Villeneuve
  2020-11-13 21:41 ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Villeneuve @ 2020-11-13 21:24 UTC (permalink / raw)
  To: libc-help

Hi,

I am compiling/linking/loading libraries from a long-running program.
I tend to reuse the same build directory and names.

But it seems that dlopen skips loading a new library if I reuse the same name as a previously (still loaded) library.
I could check that with the RTLD_NOLOAD option.
This happens even if the library itself has changed.

By looking at the code in glibc, there seems to be a test using inode/xdev, which does not rely on the name.
However, inodes can be reused immediately after unlink, so it seems fragile to infer equality of contents just comparing inodes.

In the end, I've rebuilt the library using the same name (not being sure whether the inode would be the same or not), and before dlopen, I create a hard link with a new unique name on the library and use that as arg to dlopen (and then delete the hard link).

Is this a safe way to ensure a newly built library is really loaded?
Would a symlink work? It seems that in /proc/$pid/maps, symlinks are resolved to canonical file names, so a new symlink name might not be sufficient...

Regards,
--
Daniel Villeneuve



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-23 15:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 21:24 what is the dlopen criterion used to decide if library needs to be loaded? Daniel Villeneuve
2020-11-13 21:41 ` Florian Weimer
2020-11-13 22:18   ` Daniel Villeneuve
2020-11-14 22:52     ` Daniel Villeneuve
2020-11-23 10:39       ` Florian Weimer
2020-11-23 14:42         ` Daniel Villeneuve
2020-11-23 15:12           ` Florian Weimer

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).