From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward501a.mail.yandex.net (forward501a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d501]) by sourceware.org (Postfix) with ESMTPS id 3A66238582BE for ; Wed, 29 Mar 2023 13:18:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A66238582BE 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-68.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-68.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:4c8e:0:640:3460:0]) by forward501a.mail.yandex.net (Yandex) with ESMTP id 788925EE77; Wed, 29 Mar 2023 16:18:12 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-68.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 9IInSQ2DdKo0-oHWTEcPQ; Wed, 29 Mar 2023 16:18:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680095892; bh=1xuJh9JUxdyyUjvxRj7rm2CIG4hTahVaJeW19JzJJ08=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=oYBbPjxqVnHWNjIYQ6VZxSM+Y6zpkRT2zgsq/mOReSrMMtw3fwOvCX76CIkM44vye 3n9PRhEbdT1hFi1IJcfLBJjklLf4fZsTi4fcb9u62dtwBTUv/I7E37kQoEtUIbvUyV 2s7n7GkZ8LhGeJhoLI2r9pla82ZahYkvHVgwqJfU= Authentication-Results: mail-nwsmtp-smtp-production-main-68.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Date: Wed, 29 Mar 2023 18:18:09 +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: 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.7 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: Just to be more constructive, here is the example: void *dlopen_with_offset(const char *file, off_t offset, int flags) {     off_t len;     void *addr;     void *handle;     int fd;     fd = open(file, O_RDONLY);     if (fd == -1)         return NULL;     len = lseek(fd, 0, SEEK_END);     lseek(fd, 0, SEEK_SET);     if (len <= offset)       goto err_close;     len -= offset;     /* if offset unaligned then just use read() */     if (offset & (PAGE_SIZE - 1)) {         int rd;         addr = mmap(NULL, len, PROT_READ | PROT_WRITE,                     MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);         if (addr == MAP_FAILED)             goto err_close;         rd = read(fd, addr, len);         if (rd != len) {             munmap(addr, len);             goto err_close;         }     } else {         addr = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, offset);     }     close(fd);     if (addr == MAP_FAILED)         return NULL;     handle = dlmem(addr, len, flags, NULL);     munmap(addr, len);     return handle; err_close:     close(fd);     return NULL; } Does it parse an elf headers? If so - where?