[libc-commits] [libc] [libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h (PR #149938)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 21 15:46:50 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Caslyn Tonelli (Caslyn)
<details>
<summary>Changes</summary>
An initial commit for #<!-- -->149911, this adds a stub implementation for dlinfo and the enums list of `RTLD_DI_*` values.
---
Full diff: https://github.com/llvm/llvm-project/pull/149938.diff
4 Files Affected:
- (modified) libc/include/dlfcn.yaml (+31)
- (modified) libc/src/dlfcn/CMakeLists.txt (+11)
- (added) libc/src/dlfcn/dlinfo.cpp (+22)
- (added) libc/src/dlfcn/dlinfo.h (+20)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/149938
More information about the libc-commits
mailing list