[libc-commits] [libc] [libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h (PR #149938)
Caslyn Tonelli via libc-commits
libc-commits at lists.llvm.org
Tue Aug 5 11:19:51 PDT 2025
https://github.com/Caslyn updated https://github.com/llvm/llvm-project/pull/149938
>From 96e10e4cfa6c6162ebcccbb1a0f6852d32e372b3 Mon Sep 17 00:00:00 2001
From: Caslyn Tonelli <caslyn at google.com>
Date: Mon, 21 Jul 2025 15:24:36 -0700
Subject: [PATCH 1/5] [libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h
An initial commit for #149911, this adds a stub implementation for
dlinfo and the enums list of `RTLD_DI_*` values.
---
libc/include/dlfcn.yaml | 31 +++++++++++++++++++++++++++++++
libc/src/dlfcn/CMakeLists.txt | 11 +++++++++++
libc/src/dlfcn/dlinfo.cpp | 22 ++++++++++++++++++++++
libc/src/dlfcn/dlinfo.h | 20 ++++++++++++++++++++
4 files changed, 84 insertions(+)
create mode 100644 libc/src/dlfcn/dlinfo.cpp
create mode 100644 libc/src/dlfcn/dlinfo.h
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 28be34dbd95bd..275279afb48d2 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -29,6 +29,29 @@ macros:
standards:
- gnu
macro_value: "0x01000"
+enums:
+ - name: RTLD_DI_LMID
+ value: 1
+ - name: RTLD_DI_LINKMAP
+ value: 2
+ - name: RTLD_DI_CONFIGADDR,
+ value: 3
+ - name: RTLD_DI_SERINFO
+ value: 4
+ - name: RTLD_DI_SERINFOSIZE
+ value: 5
+ - name: RTLD_DI_ORIGIN
+ value: 6
+ - name: RTLD_DI_PROFILENAME
+ value: 7
+ - name: RTLD_DI_PROFILEOUT
+ value: 8
+ - name: RTLD_DI_TLSMODID
+ value: 9
+ - name: RTLD_DI_TLS_DATA
+ value: 10
+ - name: RTLD_DI_PHDR
+ value: 11
functions:
- name: dlclose
standards:
@@ -55,3 +78,11 @@ functions:
arguments:
- type: void *__restrict
- type: const char *__restrict
+ - name: dlinfo
+ standards:
+ - GNUExtensions
+ return_type: int
+ arguments:
+ - type: void *__restrict
+ - type: int
+ - type: void *__restrict
diff --git a/libc/src/dlfcn/CMakeLists.txt b/libc/src/dlfcn/CMakeLists.txt
index e3a51ba65764d..1ee05fc380c94 100644
--- a/libc/src/dlfcn/CMakeLists.txt
+++ b/libc/src/dlfcn/CMakeLists.txt
@@ -38,3 +38,14 @@ add_entrypoint_object(
libc.include.dlfcn
libc.src.errno.errno
)
+
+add_entrypoint_object(
+ dlinfo
+ SRCS
+ dlinfo.cpp
+ HDRS
+ dlinfo.h
+ DEPENDS
+ libc.include.dlfcn
+ libc.src.errno.errno
+)
diff --git a/libc/src/dlfcn/dlinfo.cpp b/libc/src/dlfcn/dlinfo.cpp
new file mode 100644
index 0000000000000..7dae9592a9d90
--- /dev/null
+++ b/libc/src/dlfcn/dlinfo.cpp
@@ -0,0 +1,22 @@
+
+//===-- Implementation of dlinfo ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "dlinfo.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+// TODO: https://github.com/llvm/llvm-project/issues/149911
+LLVM_LIBC_FUNCTION(int, dlinfo, (void *restrict, int, void *restrict)) {
+ return -1;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/dlfcn/dlinfo.h b/libc/src/dlfcn/dlinfo.h
new file mode 100644
index 0000000000000..c2c34f02bd6f1
--- /dev/null
+++ b/libc/src/dlfcn/dlinfo.h
@@ -0,0 +1,20 @@
+//===-- Implementation header of dlinfo -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_DLFCN_DLINFO_H
+#define LLVM_LIBC_SRC_DLFCN_DLINFO_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int dlinfo(void *restrict, int, void *restrict);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_DLFCN_DLINFO_H
>From a93124ec27f1fcaf87dd4a1e98fd0b91e0addb5d Mon Sep 17 00:00:00 2001
From: Caslyn Tonelli <caslyn at google.com>
Date: Mon, 21 Jul 2025 15:54:36 -0700
Subject: [PATCH 2/5] fix typo
---
libc/include/dlfcn.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 275279afb48d2..eda0778889732 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -46,7 +46,7 @@ enums:
value: 7
- name: RTLD_DI_PROFILEOUT
value: 8
- - name: RTLD_DI_TLSMODID
+ - name: RTLD_DI_TLS_MODID
value: 9
- name: RTLD_DI_TLS_DATA
value: 10
>From d9b686e231ca43e01b7a808ccc619d27124054f1 Mon Sep 17 00:00:00 2001
From: Caslyn Tonelli <caslyn at google.com>
Date: Mon, 21 Jul 2025 15:55:09 -0700
Subject: [PATCH 3/5] add RTLD_DI_MAX
---
libc/include/dlfcn.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index eda0778889732..01b51c9cd285d 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -52,6 +52,8 @@ enums:
value: 10
- name: RTLD_DI_PHDR
value: 11
+ - name: RTLD_DI_MAX
+ value: 11
functions:
- name: dlclose
standards:
>From c09b543441b9a97df8269332435229609d10d390 Mon Sep 17 00:00:00 2001
From: Caslyn Tonelli <caslyn at google.com>
Date: Mon, 4 Aug 2025 17:17:21 -0700
Subject: [PATCH 4/5] use parameter names in the definition
---
libc/src/dlfcn/dlinfo.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/src/dlfcn/dlinfo.cpp b/libc/src/dlfcn/dlinfo.cpp
index 7dae9592a9d90..d78cade5ea593 100644
--- a/libc/src/dlfcn/dlinfo.cpp
+++ b/libc/src/dlfcn/dlinfo.cpp
@@ -15,7 +15,8 @@
namespace LIBC_NAMESPACE_DECL {
// TODO: https://github.com/llvm/llvm-project/issues/149911
-LLVM_LIBC_FUNCTION(int, dlinfo, (void *restrict, int, void *restrict)) {
+LLVM_LIBC_FUNCTION(int, dlinfo,
+ (void *restrict handle, int request, void *restrict info)) {
return -1;
}
>From 609d1c22152b274e7d667e717ed561e3617f48dd Mon Sep 17 00:00:00 2001
From: Caslyn Tonelli <caslyn at google.com>
Date: Mon, 4 Aug 2025 17:25:05 -0700
Subject: [PATCH 5/5] add gnu standard to enum members
---
libc/include/dlfcn.yaml | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 01b51c9cd285d..834cdab86109a 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -31,28 +31,52 @@ macros:
macro_value: "0x01000"
enums:
- name: RTLD_DI_LMID
+ standards:
+ - gnu
value: 1
- name: RTLD_DI_LINKMAP
+ standards:
+ - gnu
value: 2
- name: RTLD_DI_CONFIGADDR,
+ standards:
+ - gnu
value: 3
- name: RTLD_DI_SERINFO
+ standards:
+ - gnu
value: 4
- name: RTLD_DI_SERINFOSIZE
+ standards:
+ - gnu
value: 5
- name: RTLD_DI_ORIGIN
+ standards:
+ - gnu
value: 6
- name: RTLD_DI_PROFILENAME
+ standards:
+ - gnu
value: 7
- name: RTLD_DI_PROFILEOUT
+ standards:
+ - gnu
value: 8
- name: RTLD_DI_TLS_MODID
+ standards:
+ - gnu
value: 9
- name: RTLD_DI_TLS_DATA
+ standards:
+ - gnu
value: 10
- name: RTLD_DI_PHDR
+ standards:
+ - gnu
value: 11
- name: RTLD_DI_MAX
+ standards:
+ - gnu
value: 11
functions:
- name: dlclose
@@ -82,7 +106,7 @@ functions:
- type: const char *__restrict
- name: dlinfo
standards:
- - GNUExtensions
+ - gnu
return_type: int
arguments:
- type: void *__restrict
More information about the libc-commits
mailing list