mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::mods::ldso: Add wrapper for dlinfo(3).
This commit is contained in:
parent
52ad7a29ad
commit
6f3e051563
2 changed files with 24 additions and 0 deletions
|
@ -24,6 +24,8 @@ extern "C"
|
|||
/// Platform-dependent interface on ELF+ld.so supporting compilations.
|
||||
namespace ircd::mods::ldso
|
||||
{
|
||||
struct info;
|
||||
|
||||
IRCD_EXCEPTION(mods::error, error)
|
||||
IRCD_EXCEPTION(error, not_found);
|
||||
|
||||
|
@ -58,3 +60,14 @@ namespace ircd::mods::ldso
|
|||
// dlfcn suite
|
||||
bool loaded(const string_view &name);
|
||||
}
|
||||
|
||||
struct ircd::mods::ldso::info
|
||||
{
|
||||
string_view fname;
|
||||
const void *fbase {nullptr};
|
||||
string_view sname;
|
||||
const void *saddr {nullptr};
|
||||
|
||||
info(const void *const &addr);
|
||||
info() = default;
|
||||
};
|
||||
|
|
|
@ -22,6 +22,17 @@
|
|||
//
|
||||
#if defined(HAVE_DLFCN_H)
|
||||
|
||||
ircd::mods::ldso::info::info(const void *const &addr)
|
||||
{
|
||||
::Dl_info info;
|
||||
syscall(::dladdr, addr, &info);
|
||||
|
||||
fname = info.dli_fname;
|
||||
fbase = info.dli_fbase;
|
||||
sname = info.dli_sname;
|
||||
saddr = info.dli_saddr;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::mods::ldso::loaded(const string_view &name_)
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue