-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Add dlinfo + RTLD_DI_* macros to dlfcn.h #149938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An initial commit for llvm#149911, this adds a stub implementation for dlinfo and the enums list of `RTLD_DI_*` values.
Member
|
@llvm/pr-subscribers-libc Author: Caslyn Tonelli (Caslyn) ChangesAn initial commit for #149911, this adds a stub implementation for dlinfo and the enums list of Full diff: https://github.com/llvm/llvm-project/pull/149938.diff 4 Files Affected:
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
|
Caslyn
commented
Jul 21, 2025
frobtech
approved these changes
Jul 23, 2025
Contributor
frobtech
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.