From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 314DE3858CDA; Sat, 18 Mar 2023 18:14:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 314DE3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679163254; bh=a/CHFmClxvxmz9TsQX5eGKCmQYLrHWtp8AGQLCjurzk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oVWjMgLYMf8+bk5EjPX5l74xF5AbfJ9vxiHz9h9d3poxdcHb0nZvHu3LvrM7x+WSU /8wQ8OFEggqx2j8XVe5cQKp3ac+zXw8VnmgBe6CfMVrNnsC5Nfj2FYoSE6zRk+CDdY jcC7fZJtirh1JDFr4KwYlCKTFpM7OazOBLKUAZjs= From: "stsp at users dot sourceforge.net" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/30100] [patch] add dlmem() Date: Sat, 18 Mar 2023 18:14:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.38 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: stsp at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30100 --- Comment #32 from Stas Sergeev --- https://sourceware.org/pipermail/libc-alpha/2023-March/146434.html Posted a v9 with lots of new features. Also its better structured for a review. Namely the shm-dealing stuff is in the patch 13, outside of the main dlmem() impl. As this shm-dealing seems to be the last part still not well understood, I put it separately, with a separate test-case. Which, as before, maps the lib twice. Also patch 12 has an fdlopen() impl as a test-case: static void * fdlopen (int fd, int flags) { off_t len; void *addr; void *handle; len =3D lseek (fd, 0, SEEK_END); lseek (fd, 0, SEEK_SET); addr =3D mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); if (addr =3D=3D MAP_FAILED) { printf ("cannot mmap, %s\n", strerror(errno)); exit (EXIT_FAILURE); } handle =3D dlmem (addr, len, flags, NULL); munmap (addr, len); return handle; } Neither fdlopen() nor solib duplication can be done with intercepting the first mmap. Also I wonder if fdlopen() can ever be implemented simpler than that. :) The test-case for fdlopen() makes sure that /proc/self/maps have the right references to the loaded solib, rather than some anonymously mapped areas, which would be a cheating. So in fact dlmem() have suddenly grown into an universal tool that exposes all the former and new libdl features via the single small call. It can handle file-based solibs not any worse than the memory-based ones (you can even specify the solib name now). So basically, a huge libdl superset by the price of just 1 call! --=20 You are receiving this mail because: You are on the CC list for the bug.=