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?