Skip to content

Commit cfd1ee7

Browse files
authored
[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.
1 parent da6424c commit cfd1ee7

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

libc/include/dlfcn.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,55 @@ macros:
3737
standards:
3838
- gnu
3939
macro_value: "((void *) 0)"
40+
enums:
41+
- name: RTLD_DI_LMID
42+
standards:
43+
- gnu
44+
value: 1
45+
- name: RTLD_DI_LINKMAP
46+
standards:
47+
- gnu
48+
value: 2
49+
- name: RTLD_DI_CONFIGADDR,
50+
standards:
51+
- gnu
52+
value: 3
53+
- name: RTLD_DI_SERINFO
54+
standards:
55+
- gnu
56+
value: 4
57+
- name: RTLD_DI_SERINFOSIZE
58+
standards:
59+
- gnu
60+
value: 5
61+
- name: RTLD_DI_ORIGIN
62+
standards:
63+
- gnu
64+
value: 6
65+
- name: RTLD_DI_PROFILENAME
66+
standards:
67+
- gnu
68+
value: 7
69+
- name: RTLD_DI_PROFILEOUT
70+
standards:
71+
- gnu
72+
value: 8
73+
- name: RTLD_DI_TLS_MODID
74+
standards:
75+
- gnu
76+
value: 9
77+
- name: RTLD_DI_TLS_DATA
78+
standards:
79+
- gnu
80+
value: 10
81+
- name: RTLD_DI_PHDR
82+
standards:
83+
- gnu
84+
value: 11
85+
- name: RTLD_DI_MAX
86+
standards:
87+
- gnu
88+
value: 11
4089
functions:
4190
- name: dlclose
4291
standards:
@@ -63,3 +112,11 @@ functions:
63112
arguments:
64113
- type: void *__restrict
65114
- type: const char *__restrict
115+
- name: dlinfo
116+
standards:
117+
- gnu
118+
return_type: int
119+
arguments:
120+
- type: void *__restrict
121+
- type: int
122+
- type: void *__restrict

libc/src/dlfcn/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ add_entrypoint_object(
3838
libc.include.dlfcn
3939
libc.src.errno.errno
4040
)
41+
42+
add_entrypoint_object(
43+
dlinfo
44+
SRCS
45+
dlinfo.cpp
46+
HDRS
47+
dlinfo.h
48+
DEPENDS
49+
libc.include.dlfcn
50+
libc.src.errno.errno
51+
)

libc/src/dlfcn/dlinfo.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
//===-- Implementation of dlinfo ------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include "dlinfo.h"
11+
12+
#include "src/__support/common.h"
13+
#include "src/__support/macros/config.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
// TODO: https://github.com/llvm/llvm-project/issues/149911
18+
LLVM_LIBC_FUNCTION(int, dlinfo,
19+
(void *restrict handle, int request, void *restrict info)) {
20+
return -1;
21+
}
22+
23+
} // namespace LIBC_NAMESPACE_DECL

libc/src/dlfcn/dlinfo.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header of dlinfo -------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_DLFCN_DLINFO_H
10+
#define LLVM_LIBC_SRC_DLFCN_DLINFO_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
int dlinfo(void *restrict, int, void *restrict);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_DLFCN_DLINFO_H

0 commit comments

Comments
 (0)