[libc-commits] [libc] cfd1ee7 - [libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h (#149938)
via libc-commits
libc-commits at lists.llvm.org
Tue Aug 5 13:34:33 PDT 2025
Author: Caslyn Tonelli
Date: 2025-08-05T13:34:30-07:00
New Revision: cfd1ee781f116de891cd802b277b67a698acad60
URL: https://github.com/llvm/llvm-project/commit/cfd1ee781f116de891cd802b277b67a698acad60
DIFF: https://github.com/llvm/llvm-project/commit/cfd1ee781f116de891cd802b277b67a698acad60.diff
LOG: [libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h (#149938)
An initial commit for #149911, this adds a stub implementation for
dlinfo and the enums list of `RTLD_DI_*` values.
While the dlinfo implementation relies on dynamic linker support, this
patch will add its prototype in the generated dlfcn.h header so that it
can be used by downstream platforms that have their own dlinfo
implementation.
Added:
libc/src/dlfcn/dlinfo.cpp
libc/src/dlfcn/dlinfo.h
Modified:
libc/include/dlfcn.yaml
libc/src/dlfcn/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 6afeb70b89e76..a8218b6780c2c 100644
--- a/libc/include/dlfcn.yaml
+++ b/libc/include/dlfcn.yaml
@@ -37,6 +37,55 @@ macros:
standards:
- gnu
macro_value: "((void *) 0)"
+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
standards:
@@ -63,3 +112,11 @@ functions:
arguments:
- type: void *__restrict
- type: const char *__restrict
+ - name: dlinfo
+ standards:
+ - gnu
+ 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..d78cade5ea593
--- /dev/null
+++ b/libc/src/dlfcn/dlinfo.cpp
@@ -0,0 +1,23 @@
+
+//===-- 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 handle, int request, void *restrict info)) {
+ 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
More information about the libc-commits
mailing list