From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt42.smtp-out.videotron.ca (alt42.smtp-out.videotron.ca [23.233.128.29]) by sourceware.org (Postfix) with ESMTPS id 52D4D3950C30 for ; Fri, 13 Nov 2020 21:24:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 52D4D3950C30 Received: from [192.168.0.100] ([96.20.238.10]) by Videotron with SMTP id dgYHkhTJYbSemdgYJkPCqw; Fri, 13 Nov 2020 16:24:16 -0500 X-Authority-Analysis: v=2.3 cv=COhUoijD c=1 sm=1 tr=0 a=IvhzMnQCxHlOtQqA98XSUg==:117 a=IvhzMnQCxHlOtQqA98XSUg==:17 a=IkcTkHD0fZMA:10 a=x7bEGLp0ZPQA:10 a=rvM64S1SdSMA:10 a=LNTmeLK8CkXgW3lBoG4A:9 a=QEXdDO2ut3YA:10 To: libc-help@sourceware.org From: Daniel Villeneuve Subject: what is the dlopen criterion used to decide if library needs to be loaded? Message-ID: Date: Fri, 13 Nov 2020 16:24:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-CMAE-Envelope: MS4wfDSSIKr8HASfnt0PP0FHArP+Y3rnitYD+HC334AgkpLcgB0yqiqkXCrFAclqlQtwCBb+3xcN/UXhCMGy/ZRzU2Vr70CJlzXrtzbTqkgNgVACj3D2f8O7 FLTJjjcXzCzu3Y0obdXEO/b29PGP3Eo0Uq8tZy7pngwej8aRBGuhmGzD6+eoMxrSUpJsKfd8819qbQ== X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_DMARC_NONE, KAM_DMARC_STATUS, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, SPOOFED_FREEMAIL, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Nov 2020 21:24:18 -0000 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