public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Villeneuve <dvilleneuve.4142@gmail.com>
To: libc-help@sourceware.org
Subject: what is the dlopen criterion used to decide if library needs to be loaded?
Date: Fri, 13 Nov 2020 16:24:13 -0500	[thread overview]
Message-ID: <cb867a8c-26c4-0415-5d95-b7ffb9c2242a@gmail.com> (raw)

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



             reply	other threads:[~2020-11-13 21:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 21:24 Daniel Villeneuve [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb867a8c-26c4-0415-5d95-b7ffb9c2242a@gmail.com \
    --to=dvilleneuve.4142@gmail.com \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).