From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward501c.mail.yandex.net (forward501c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d501]) by sourceware.org (Postfix) with ESMTPS id DB4CC3858D32 for ; Fri, 31 Mar 2023 19:00:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB4CC3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5c2c:0:640:93c4:0]) by forward501c.mail.yandex.net (Yandex) with ESMTP id AB19B5E5BA; Fri, 31 Mar 2023 22:00:06 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 20Qndc7WtSw0-Sl2NYvCF; Fri, 31 Mar 2023 22:00:06 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680289206; bh=0oR77djisSqj2Z8fzR9fAUf8uyExWvpPEerh6sIiP9E=; h=In-Reply-To:References:To:Subject:Message-ID:Date:From; b=JmoOmrhm5IoNj0Ok2iz3OV8pWYDlE/PaqK33bbPOTLlHslSyC7yNF3QemyMy5/Iey phMB7JtUwuyBTNCNJP3mmJJmBH1lkw6fWOKw/fCkECRguzYNDOKEVnVC6ZOjS7+fK/ e5E+lVwK0tFl45oZJkhEO1Pdw7cMYGufnbwfgmeE= Authentication-Results: mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: multipart/alternative; boundary="------------cd6hOAJHmLn9mLdwhcJjAdB5" Message-ID: Date: Sat, 1 Apr 2023 00:00:02 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v9 0/13] implement dlmem() function Content-Language: en-US From: stsp To: Szabolcs Nagy , Adhemerval Zanella Netto , libc-alpha@sourceware.org, janderson@rice.edu, Carlos O'Donell , Rich Felker References: <20230318165110.3672749-1-stsp2@yandex.ru> <2f3a10fa-4f79-7f9a-6407-d227dbf31935@yandex.ru> <592021ae-8f69-d411-c278-054ca003ef47@yandex.ru> In-Reply-To: <592021ae-8f69-d411-c278-054ca003ef47@yandex.ru> X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------cd6hOAJHmLn9mLdwhcJjAdB5 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Szabolcs, 31.03.2023 23:47, stsp пишет: > > 31.03.2023 22:12, Szabolcs Nagy пишет: >> your dlmem design it passes down a user callback that runs >> under dynamic linker locks to map segments. > Oh, I missed that sentence initially. > No, its not to map segments. > Its to do the single initial mmap() only. > The segments are of course all mapped > by the loader internally. > Which is why this callback is optional and > should almost never be used. > > Does this clarification help? Actually let me show you the fdlopen() example on top of dlmem, to make it crystal clear that the premap callback has nothing to do with anything, and should just be ignored: static void * fdlopen (int fd, int flags) {   off_t len;   void *addr;   void *handle;   len = lseek (fd, 0, SEEK_END);   lseek (fd, 0, SEEK_SET);   addr = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);   if (addr == MAP_FAILED)     {       printf ("cannot mmap, %s\n", strerror(errno));       exit (EXIT_FAILURE);     }   handle = dlmem (addr, len, flags, NULL);   munmap (addr, len);   return handle; } After running this code, we have this /proc/self/maps: 7fb413101000-7fb413102000 r--p 00000000 00:28 17195405 /home/stas/src/glibc-dev/build/dlfcn/glreflib1.so 7fb413102000-7fb413103000 r-xp 00001000 00:28 17195405 /home/stas/src/glibc-dev/build/dlfcn/glreflib1.so 7fb413103000-7fb413104000 r--p 00002000 00:28 17195405 /home/stas/src/glibc-dev/build/dlfcn/glreflib1.so 7fb413104000-7fb413105000 r--p 00002000 00:28 17195405 /home/stas/src/glibc-dev/build/dlfcn/glreflib1.so 7fb413105000-7fb413106000 rw-p 00003000 00:28 17195405 /home/stas/src/glibc-dev/build/dlfcn/glreflib1.so So the callback is not involved. As you can see its set to NULL. The loader is fully capable, callback is not needed. Does this clarify? --------------cd6hOAJHmLn9mLdwhcJjAdB5--