From: Qixing Xue <qixingxue@outlook.com>
To: "libc-help@sourceware.org" <libc-help@sourceware.org>
Subject: Asking for consideration behind making RTLD_DI_SERINFOSIZE request twice
Date: Wed, 12 Apr 2023 15:50:59 +0000 [thread overview]
Message-ID: <ME2P282MB2242B7D274B3A0D943AF552FB49B9@ME2P282MB2242.AUSP282.PROD.OUTLOOK.COM> (raw)
[-- Attachment #1: Type: text/plain, Size: 1754 bytes --]
Hi,
Recently I am working with dlinfo and from my understanding of the use of RTLD_DI_SERINFO in [dlinfo](https://man7.org/linux/man-pages/man3/dlinfo.3.html), the first call gives dls_size value that helps ensure the struct is large enough, but the second call is seemly doing nothing new but repeating computation of first call to fill out the two fields dls_size and dls_cnt. Besides, from the [code called](https://elixir.bootlin.com/glibc/glibc-2.37.9000/source/elf/dl-load.c#L2298) by the dlopen [interface](https://elixir.bootlin.com/glibc/glibc-2.37.9000/source/dlfcn/dlinfo.c#L63), I am unable to locate some code distinguishing the two calls and therefore my question is whether this two-step call sequence is something really necessary, or is it already enough to just copy over the stats like cnt and size, through, for example, having a new request item called RTLD_DI_SERINFOSIZE_COPY to provide some forward compatibility from library authors’ viewpoint. As a running example, the following code prints two exact same line on my machine.
```c
Dl_serinfo dl_search_size;
if (dlinfo(dl_handle, RTLD_DI_SERINFOSIZE, &dl_search_size)) {
printf("dlinfo: %s while populating search info size", dlerror());
return;
}
printf("%d %ld\n", dl_search_size.dls_cnt, dl_search_size.dls_size);
Dl_serinfo *dl_search_info = (Dl_serinfo *)malloc(dl_search_size.dls_size);
if (!dl_search_info) {
perror("malloc");
return;
}
if (dlinfo(dl_handle, RTLD_DI_SERINFOSIZE, dl_search_info)) {
printf("dlinfo: %s while ", dlerror());
return;
}
printf("%d %ld\n", dl_search_info->dls_cnt, dl_search_info->dls_size);
```
Thanks a lot for your attention and hope you a great day.
Best,
Qixing
reply other threads:[~2023-04-12 15:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ME2P282MB2242B7D274B3A0D943AF552FB49B9@ME2P282MB2242.AUSP282.PROD.OUTLOOK.COM \
--to=qixingxue@outlook.com \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).