[v1,1/2] support: Add xdlinfo error-checking wrapper
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
Commit Message
Provide an error-checking wrapper xdlinfo for dlinfo in the support
library. Unlike simple non-zero checks, xdlinfo treats negative return
values (res < 0) as errors, allowing requests like RTLD_DI_PHDR that
return positive values (such as program header count) to succeed without
abnormal termination.
---
support/Makefile | 1 +
support/xdlfcn.h | 1 +
support/xdlinfo.c | 29 +++++++++++++++++++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 support/xdlinfo.c
base-commit: 6c82d5c83f3f46729f110220644d96ab7ab4cd78
Comments
On 27/10/26 07:45, Frédéric Bérat wrote:
> Provide an error-checking wrapper xdlinfo for dlinfo in the support
> library. Unlike simple non-zero checks, xdlinfo treats negative return
> values (res < 0) as errors, allowing requests like RTLD_DI_PHDR that
> return positive values (such as program header count) to succeed without
> abnormal termination.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> support/Makefile | 1 +
> support/xdlfcn.h | 1 +
> support/xdlinfo.c | 29 +++++++++++++++++++++++++++++
> 3 files changed, 31 insertions(+)
> create mode 100644 support/xdlinfo.c
>
> diff --git a/support/Makefile b/support/Makefile
> index 737aa38759..bc1fd444db 100644
> --- a/support/Makefile
> +++ b/support/Makefile
> @@ -151,6 +151,7 @@ libsupport-routines = \
> xconnect \
> xcopy_file_range \
> xdlfcn \
> + xdlinfo \
> xdlmopen \
> xdup \
> xdup2 \
> diff --git a/support/xdlfcn.h b/support/xdlfcn.h
> index 54f61adb93..db53881df3 100644
> --- a/support/xdlfcn.h
> +++ b/support/xdlfcn.h
> @@ -28,6 +28,7 @@ void *xdlopen (const char *filename, int flags);
> void *xdlmopen (Lmid_t lmid, const char *filename, int flags);
> void *xdlsym (void *handle, const char *symbol);
> void *xdlvsym (void *handle, const char *symbol, const char *version);
> +int xdlinfo (void *handle, int request, void *arg);
> void xdlclose (void *handle);
>
> __END_DECLS
> diff --git a/support/xdlinfo.c b/support/xdlinfo.c
> new file mode 100644
> index 0000000000..e00358b709
> --- /dev/null
> +++ b/support/xdlinfo.c
> @@ -0,0 +1,29 @@
> +/* dlinfo with error checking.
> + Copyright (C) 2026 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <support/check.h>
> +#include <support/xdlfcn.h>
> +
> +int
> +xdlinfo (void *handle, int request, void *arg)
> +{
> + int res = dlinfo (handle, request, arg);
> + if (res < 0)
> + FAIL_EXIT1 ("error: dlinfo: %s\n", dlerror ());
> + return res;
> +}
>
> base-commit: 6c82d5c83f3f46729f110220644d96ab7ab4cd78
On Tue, Oct 27, 2026 at 6:45 AM Frédéric Bérat <fberat@redhat.com> wrote:
> + xdlinfo \
Ok.
> +int xdlinfo (void *handle, int request, void *arg);
Ok.
> +/* dlinfo with error checking.
> + Copyright (C) 2026 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> . . .
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <support/check.h>
> +#include <support/xdlfcn.h>
Ok.
> +int
> +xdlinfo (void *handle, int request, void *arg)
> +{
> + int res = dlinfo (handle, request, arg);
> + if (res < 0)
> + FAIL_EXIT1 ("error: dlinfo: %s\n", dlerror ());
> + return res;
> +}
Ok.
LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
@@ -151,6 +151,7 @@ libsupport-routines = \
xconnect \
xcopy_file_range \
xdlfcn \
+ xdlinfo \
xdlmopen \
xdup \
xdup2 \
@@ -28,6 +28,7 @@ void *xdlopen (const char *filename, int flags);
void *xdlmopen (Lmid_t lmid, const char *filename, int flags);
void *xdlsym (void *handle, const char *symbol);
void *xdlvsym (void *handle, const char *symbol, const char *version);
+int xdlinfo (void *handle, int request, void *arg);
void xdlclose (void *handle);
__END_DECLS
new file mode 100644
@@ -0,0 +1,29 @@
+/* dlinfo with error checking.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xdlfcn.h>
+
+int
+xdlinfo (void *handle, int request, void *arg)
+{
+ int res = dlinfo (handle, request, arg);
+ if (res < 0)
+ FAIL_EXIT1 ("error: dlinfo: %s\n", dlerror ());
+ return res;
+}