Implement dladdr() (partially)

Note that this always returns with dli_sname and dli_saddr set to NULL,
indicating no symbol matching addr could be found.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
This commit is contained in:
Jon Turney
2017-03-06 18:30:45 +00:00
parent 51a993c266
commit c8432a01c8
6 changed files with 61 additions and 1 deletions

View File

@@ -472,12 +472,13 @@ details. */
305: [f]pathconf flag _PC_CASE_INSENSITIVE added.
306: Export getentropy, getrandom.
307: Export timingsafe_bcmp, timingsafe_memcmp.
308: Export dladdr.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 307
#define CYGWIN_VERSION_API_MINOR 308
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared

View File

@@ -9,6 +9,9 @@ details. */
#ifndef _DLFCN_H
#define _DLFCN_H
#include <sys/cdefs.h>
#include <limits.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -42,6 +45,21 @@ extern void dlfork (int);
#define RTLD_DEEPBIND 32 /* Place lookup scope so that this lib is */
/* preferred over global scope. */
#if __GNU_VISIBLE
typedef struct Dl_info Dl_info;
struct Dl_info
{
char dli_fname[PATH_MAX]; /* Filename of defining object */
void *dli_fbase; /* Load address of that object */
const char *dli_sname; /* Name of nearest lower symbol */
void *dli_saddr; /* Exact value of nearest symbol */
};
extern int dladdr (const void *addr, Dl_info *info);
#endif
#ifdef __cplusplus
}
#endif