Skip to content

Commit 3df7a20

Browse files
[libc] Install dladdr on X86
This patch adds dladdr to the X86 entrypoints and also does the necessary plumbing so that dladdr.cpp will actually compile. This depends on llvm#156195.
1 parent f99b0f3 commit 3df7a20

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(TARGET_LIBC_ENTRYPOINTS
1818
libc.src.ctype.toupper
1919

2020
# dlfcn.h entrypoints
21+
libc.src.dlfcn.dladdr
2122
libc.src.dlfcn.dlclose
2223
libc.src.dlfcn.dlerror
2324
libc.src.dlfcn.dlopen

libc/hdr/types/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,12 @@ add_proxy_header_library(
461461
libc.include.llvm-libc-types.struct_sched_param
462462
libc.include.sched
463463
)
464+
465+
add_proxy_header_library(
466+
dl_info
467+
HDRS
468+
dl_info.h
469+
FULL_BUILD_DEPENDS
470+
libc.include.llvm-libc-types.dl_info
471+
libc.include.dlfcn
472+
)

libc/hdr/types/dl_info.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Proxy for struct timespec ----------------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_TYPES_DLINFO_H
9+
#define LLVM_LIBC_HDR_TYPES_DLINFO_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/Dl_info.h"
14+
15+
#else
16+
17+
#include <dlfcn.h>
18+
19+
#endif // LIBC_FULL_BUILD
20+
21+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_TIMESPEC_H

libc/src/dlfcn/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ add_entrypoint_object(
5454
dladdr.h
5555
DEPENDS
5656
libc.include.dlfcn
57+
libc.hdr.types.dl_info
5758
)

libc/src/dlfcn/dladdr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL {
1515

1616
// TODO: https:// github.com/llvm/llvm-project/issues/97929
1717
LLVM_LIBC_FUNCTION(int, dladdr,
18-
(const void *__restrict addr, Dl_info *__restrict info)) {
18+
([[maybe_unused]] const void *__restrict addr,
19+
[[maybe_unused]] Dl_info *__restrict info)) {
1920
return -1;
2021
}
2122

libc/src/dlfcn/dladdr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "src/__support/macros/config.h"
1313

14+
#include "hdr/types/dl_info.h"
15+
1416
namespace LIBC_NAMESPACE_DECL {
1517

1618
int dladdr(const void *__restrict, Dl_info *__restrict);

0 commit comments

Comments
 (0)