File tree Expand file tree Collapse file tree 6 files changed +61
-1
lines changed Expand file tree Collapse file tree 6 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,7 @@ difftime NOSIGFE
364
364
dirfd SIGFE
365
365
dirname NOSIGFE
366
366
div NOSIGFE
367
+ dladdr SIGFE
367
368
dlclose SIGFE
368
369
dlerror NOSIGFE
369
370
dlfork NOSIGFE
Original file line number Diff line number Diff line change @@ -386,3 +386,37 @@ dlerror ()
386
386
}
387
387
return res;
388
388
}
389
+
390
+ extern " C" int
391
+ dladdr (const void *addr, Dl_info *info)
392
+ {
393
+ HMODULE hModule;
394
+ BOOL ret = GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
395
+ (LPCSTR) addr,
396
+ &hModule);
397
+ if (!ret)
398
+ return 0 ;
399
+
400
+ /* Module handle happens to be equal to it's base load address. */
401
+ info->dli_fbase = hModule;
402
+
403
+ /* Get the module filename. This pathname may be in short-, long- or //?/
404
+ format, depending on how it was specified when loaded, but we assume this
405
+ is always an absolute pathname. */
406
+ WCHAR fname[MAX_PATH];
407
+ DWORD length = GetModuleFileNameW (hModule, fname, MAX_PATH);
408
+ if ((length == 0 ) || (length == MAX_PATH))
409
+ return 0 ;
410
+
411
+ /* Convert to a cygwin pathname */
412
+ ssize_t conv = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, fname,
413
+ info->dli_fname , MAX_PATH);
414
+ if (conv)
415
+ return 0 ;
416
+
417
+ /* Always indicate no symbol matching addr could be found. */
418
+ info->dli_sname = NULL ;
419
+ info->dli_saddr = NULL ;
420
+
421
+ return 1 ;
422
+ }
Original file line number Diff line number Diff line change @@ -472,12 +472,13 @@ details. */
472
472
305: [f]pathconf flag _PC_CASE_INSENSITIVE added.
473
473
306: Export getentropy, getrandom.
474
474
307: Export timingsafe_bcmp, timingsafe_memcmp.
475
+ 308: Export dladdr.
475
476
476
477
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
477
478
sigaltstack, sethostname. */
478
479
479
480
#define CYGWIN_VERSION_API_MAJOR 0
480
- #define CYGWIN_VERSION_API_MINOR 307
481
+ #define CYGWIN_VERSION_API_MINOR 308
481
482
482
483
/* There is also a compatibity version number associated with the shared memory
483
484
regions. It is incremented when incompatible changes are made to the shared
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ details. */
9
9
#ifndef _DLFCN_H
10
10
#define _DLFCN_H
11
11
12
+ #include <sys/cdefs.h>
13
+ #include <limits.h>
14
+
12
15
#ifdef __cplusplus
13
16
extern "C" {
14
17
#endif
@@ -42,6 +45,21 @@ extern void dlfork (int);
42
45
#define RTLD_DEEPBIND 32 /* Place lookup scope so that this lib is */
43
46
/* preferred over global scope. */
44
47
48
+
49
+ #if __GNU_VISIBLE
50
+ typedef struct Dl_info Dl_info ;
51
+
52
+ struct Dl_info
53
+ {
54
+ char dli_fname [PATH_MAX ]; /* Filename of defining object */
55
+ void * dli_fbase ; /* Load address of that object */
56
+ const char * dli_sname ; /* Name of nearest lower symbol */
57
+ void * dli_saddr ; /* Exact value of nearest symbol */
58
+ };
59
+
60
+ extern int dladdr (const void * addr , Dl_info * info );
61
+ #endif
62
+
45
63
#ifdef __cplusplus
46
64
}
47
65
#endif
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ What's new:
3
3
4
4
- New API: timingsafe_bcmp, timingsafe_memcmp
5
5
6
+ - New API: dladdr
7
+
6
8
What changed:
7
9
-------------
8
10
Original file line number Diff line number Diff line change @@ -1277,6 +1277,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
1277
1277
clog10
1278
1278
clog10f
1279
1279
clog10l
1280
+ dladdr (see chapter "Implementation Notes")
1280
1281
dremf
1281
1282
dup3
1282
1283
envz_add
@@ -1665,6 +1666,9 @@ depending on whether _BSD_SOURCE or _GNU_SOURCE is defined when compiling.</para
1665
1666
<para ><function >basename</function > is available in both POSIX and GNU flavors,
1666
1667
depending on whether libgen.h is included or not.</para >
1667
1668
1669
+ <para ><function >dladdr</function > always sets the Dl_info members dli_sname and
1670
+ dli_saddr to NULL, indicating no symbol matching addr could be found.</para >
1671
+
1668
1672
</sect1 >
1669
1673
1670
1674
</chapter >
You can’t perform that action at this time.
0 commit comments