[libc] Add dladdr to dlfcn.h (#149872)
A initial commit for #97929, this adds a stub implementation for `dladdr` and includes the definition for the `DL_info` type used as one of its arguments. While the `dladdr` 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 `dladdr` implementation.
This commit is contained in:
parent
07da480614
commit
5a076e3b4d
@ -86,6 +86,8 @@ enums:
|
||||
standards:
|
||||
- gnu
|
||||
value: 11
|
||||
types:
|
||||
- type_name: Dl_info
|
||||
functions:
|
||||
- name: dlclose
|
||||
standards:
|
||||
@ -120,3 +122,10 @@ functions:
|
||||
- type: void *__restrict
|
||||
- type: int
|
||||
- type: void *__restrict
|
||||
- name: dladdr
|
||||
standards:
|
||||
- POSIX
|
||||
return_type: int
|
||||
arguments:
|
||||
- type: const void *
|
||||
- type: Dl_info *
|
||||
|
19
libc/include/llvm-libc-types/Dl_info.h
Normal file
19
libc/include/llvm-libc-types/Dl_info.h
Normal file
@ -0,0 +1,19 @@
|
||||
//===-- Definition of Dl_info type ----------------------------------------===//
|
||||
//
|
||||
// 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_TYPES_DL_INFO_H
|
||||
#define LLVM_LIBC_TYPES_DL_INFO_H
|
||||
|
||||
typedef struct {
|
||||
const char *dli_fname;
|
||||
void *dli_fbase;
|
||||
const char *dli_sname;
|
||||
void *dli_saddr;
|
||||
} Dl_info;
|
||||
|
||||
#endif // LLVM_LIBC_TYPES_DL_INFO_H
|
@ -49,3 +49,14 @@ add_entrypoint_object(
|
||||
libc.include.dlfcn
|
||||
libc.src.errno.errno
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
dladdr
|
||||
SRCS
|
||||
dladdr.cpp
|
||||
HDRS
|
||||
dladdr.h
|
||||
DEPENDS
|
||||
libc.include.dlfcn
|
||||
libc.src.errno.errno
|
||||
)
|
||||
|
21
libc/src/dlfcn/dladdr.cpp
Normal file
21
libc/src/dlfcn/dladdr.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation of dladdr ------------------------------------------===//
|
||||
//
|
||||
// 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 "dladdr.h"
|
||||
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
// TODO: https:// github.com/llvm/llvm-project/issues/97929
|
||||
LLVM_LIBC_FUNCTION(int, dladdr, (const void *addr, Dl_info *info)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
20
libc/src/dlfcn/dladdr.h
Normal file
20
libc/src/dlfcn/dladdr.h
Normal file
@ -0,0 +1,20 @@
|
||||
//===-- Implementation header of dladdr -------------------------*- 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_DLADDR_H
|
||||
#define LLVM_LIBC_SRC_DLFCN_DLADDR_H
|
||||
|
||||
#include "src/__support/macros/config.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
int dladdr(const void *, Dl_info *);
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC_DLFCN_DLADDR_H
|
Loading…
x
Reference in New Issue
Block a user