aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaslyn Tonelli <6718161+Caslyn@users.noreply.github.com>2025-08-05 13:34:30 -0700
committerGitHub <noreply@github.com>2025-08-05 13:34:30 -0700
commitcfd1ee781f116de891cd802b277b67a698acad60 (patch)
treee8c981e931a6432b317bfaa24021b454dc06f8c3
parentda6424c9e307cd324f37745b525d3884b5077707 (diff)
downloadllvm-cfd1ee781f116de891cd802b277b67a698acad60.zip
llvm-cfd1ee781f116de891cd802b277b67a698acad60.tar.gz
llvm-cfd1ee781f116de891cd802b277b67a698acad60.tar.bz2
[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.
-rw-r--r--libc/include/dlfcn.yaml57
-rw-r--r--libc/src/dlfcn/CMakeLists.txt11
-rw-r--r--libc/src/dlfcn/dlinfo.cpp23
-rw-r--r--libc/src/dlfcn/dlinfo.h20
4 files changed, 111 insertions, 0 deletions
diff --git a/libc/include/dlfcn.yaml b/libc/include/dlfcn.yaml
index 6afeb70..a8218b6 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 e3a51ba..1ee05fc 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 0000000..d78cade
--- /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 0000000..c2c34f0
--- /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