From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward501b.mail.yandex.net (forward501b.mail.yandex.net [178.154.239.145]) by sourceware.org (Postfix) with ESMTPS id 8E3933858D28 for ; Fri, 31 Mar 2023 15:12:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E3933858D28 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-92.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:131b:0:640:f0f5:0]) by forward501b.mail.yandex.net (Yandex) with ESMTP id 73C9A5E896; Fri, 31 Mar 2023 18:12:37 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id YCMAfpEDfuQ0-Bjn3YoDZ; Fri, 31 Mar 2023 18:12:36 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680275556; bh=jy89837/n5o8jUIYlV5insDjsJeJrLWxryv7SMCY6UY=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=Sqly8iE5F2RjXs+TLXdwIsjaVt5ihvJRmHIIXu4eu6zCAbbv+Gttymudxy63wxsTx c9hAzIaAYgtAlshRDzZ/b1lZVYL/uvA4z+tKoWvhO718G6PpeSRq7e9MEoMAzlGfhD 2HCNoGNpfRpPDgUeGjsZfC81HNZFaeI1P7VH4hCs= Authentication-Results: mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <2f3a10fa-4f79-7f9a-6407-d227dbf31935@yandex.ru> Date: Fri, 31 Mar 2023 20:12:33 +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 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> From: stsp In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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,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: Hi Szabolcs, I need to try again with answering this. 31.03.2023 17:20, Szabolcs Nagy пишет: > The 03/29/2023 18:18, stsp via Libc-alpha wrote: >> Just to be more constructive, here is the >> example: >> >> void *dlopen_with_offset(const char *file, off_t offset, int flags) >> { > this api requires no libc change: > > dump the contents to a temp file and use dlopen on it. This doesn't work for my use-case. dlmem() can optionally preserve the destination mapping, which is not possible by definition with any file-based API. > it creates a mapping that's not compatible with dynamic loading > requirements *depending on* what the elf headers say. > (elf segments may be loaded at various offsets that can conflict > with the mapping that you just made) No, conflict is not possible as they are loaded to entirely separately mmapped buffer. And I have a proof that this works as expected: $ LD_LIBRARY_PATH=..:. ./tst-dlmem-fdlopen unaligned buf gives buffer not aligned: Invalid argument 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 In this example you see 5 references to the solib, all created by dlmem. There is no conflict with the initial buffer, such conflict is not even possible.