Mercurial > pub > dyncall > dyncall
annotate dynload/dynload.3 @ 308:7c6f19d42b31
dynload UTF-8 support for library paths:
- added missing support to windows
- added test code for all platforms to dynload_plain
- doc update
author | Tassilo Philipp |
---|---|
date | Thu, 24 Oct 2019 23:19:20 +0200 |
parents | 5cfe4322c500 |
children | 3840e0188520 |
rev | line source |
---|---|
216
28bf0b231bce
- dynload man page clarification about resolving own symbols
Tassilo Philipp
parents:
93
diff
changeset
|
1 .\" Copyright (c) 2007-2017 Daniel Adler <dadler AT uni-goettingen DOT de>, |
0 | 2 .\" Tassilo Philipp <tphilipp AT potion-studios DOT com> |
3 .\" | |
4 .\" Permission to use, copy, modify, and distribute this software for any | |
5 .\" purpose with or without fee is hereby granted, provided that the above | |
6 .\" copyright notice and this permission notice appear in all copies. | |
7 .\" | |
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 .\" | |
16 .Dd $Mdocdate$ | |
17 .Dt dynload 3 | |
18 .Sh NAME | |
19 .Nm dynload | |
20 .Nd encapsulates dynamic loading mechanisms and | |
21 gives access to functions in foreign dynamic libraries and code modules. | |
22 .Sh SYNOPSIS | |
23 .In dynload.h | |
24 .Ft DLLib * | |
25 .Fn dlLoadLibrary "const char * libpath" | |
26 .Ft void | |
27 .Fn dlFreeLibrary "DLLib * pLib" | |
28 .Ft void * | |
216
28bf0b231bce
- dynload man page clarification about resolving own symbols
Tassilo Philipp
parents:
93
diff
changeset
|
29 .Fn dlFindSymbol "DLLib * pLib" "const char * pSymbolName" |
243 | 30 .Ft int |
31 .Fn dlGetLibraryPath "DLLib * pLib" "char * sOut" "int bufSize" | |
228 | 32 .Ft DLSyms* |
33 .Fn dlSymsInit "const char * libPath" | |
34 .Ft void | |
35 .Fn dlSymsCleanup "DLSyms * pSyms" | |
36 .Ft int | |
37 .Fn dlSymsCount "DLSyms * pSyms" | |
38 .Ft const char* | |
39 .Fn dlSymsName "DLSyms * pSyms" "int index" | |
40 .Ft const char* | |
41 .Fn dlSymsNameFromValue "DLSyms * pSyms" "void * value" | |
0 | 42 .Sh DESCRIPTION |
43 The | |
44 .Nm | |
45 library provides an interface to load foreign dynamic libraries and access | |
46 to their symbols. | |
47 .Pp | |
48 .Fn dlLoadLibrary | |
49 loads a dynamic library at | |
50 .Ar libpath | |
51 and returns a handle to it for use in | |
52 .Fn dlFreeLibrary | |
53 and | |
54 .Fn dlFindSymbol | |
216
28bf0b231bce
- dynload man page clarification about resolving own symbols
Tassilo Philipp
parents:
93
diff
changeset
|
55 calls. Passing a null pointer for the |
28bf0b231bce
- dynload man page clarification about resolving own symbols
Tassilo Philipp
parents:
93
diff
changeset
|
56 .Ar libpath |
308 | 57 argument is valid, and returns a handle to the main executable of the calling code. Also, searching libraries in library paths (e.g. by just passing the library's leaf name) should work, however, they are OS specific. The |
58 .Ar libPath | |
59 argument is expected to be UTF-8 encoded. Returns a null pointer on error. | |
0 | 60 .Pp |
61 .Fn dlFreeLibrary | |
62 frees the loaded library with handle | |
63 .Ar pLib . | |
64 .Pp | |
65 .Fn dlFindSymbol | |
66 returns a pointer to a symbol with name | |
67 .Ar pSymbolName | |
68 in the library with handle | |
69 .Ar pLib , | |
223
7076f551faf5
- dynload mach-o handling fixes for 64bit platforms
Tassilo Philipp
parents:
216
diff
changeset
|
70 or returns a null pointer if the symbol cannot be found. The name is specified as it would appear in C source code (mangled if C++, etc.). |
228 | 71 .Pp |
243 | 72 .Fn dlGetLibraryPath |
73 can be used to get a copy of the path to the library loaded with handle | |
74 .Ar pLib . | |
75 The parameter | |
76 .Ar sOut | |
77 is a pointer to a buffer of size | |
78 .Ar bufSize | |
308 | 79 (in bytes), to hold the output string (UTF-8 encoded). The return value is the size of the buffer (in bytes) needed to hold the null-terminated string, or 0 if it can't be looked up. If |
243 | 80 .Ar bufSize |
308 | 81 >= return value >= 1, a null-terminted string with the path to the library should be in |
243 | 82 .Ar sOut . |
248 | 83 If it returns 0, the library name wasn't able to be found. Please note that this might happen in some rare cases, so make sure to always check. |
243 | 84 .Pp |
85 The dlSyms* functions can be used to iterate over symbols. Since they can be used on libraries that are not linked, they are made | |
86 for symbol name lookups, not to get symbols' addresses. For that refer to | |
228 | 87 .Fn dlFindSymbol . |
88 .Fn dlSymsInit | |
89 will return a handle (or null pointer on error) to the shared object specified by | |
243 | 90 .Ar libPath , |
91 to be used with the other dlSyms* functions. Note that contrary to loading and linking libraries, no (OS-specific) rules for searching libraries in library paths, etc. apply. The handle must be freed with | |
228 | 92 .Fn dlSymsCleanup . |
93 .Fn dlSymsCount | |
94 returns the number of symbols in the shared object, | |
95 .Fn dlSymsName | |
96 and | |
97 .Fn dlSymsNameFromValue | |
98 are used to lookup symbol names using an index or symbol's address, respectively, returning a null pointer on error. The names are returned as they would appear in C source code (mangled if C++, etc.). The address passed to | |
99 .Fn dlSymsNameFromValue | |
100 must point to a loaded symbol. | |
243 | 101 .Sh BUGS |
102 .Fn dlGetLibraryPath | |
248 | 103 is not thread-safe on Darwin (macOS, iOS, ...) and OpenBSD. |
243 | 104 .Fn dlSymsInit |
248 | 105 is not thread-safe on Darwin. |
106 .Fn dlGetLibraryPath | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
250
diff
changeset
|
107 will not work on the following platforms when the library in question doesn't have the (default) |
248 | 108 .Fn _init |
109 and | |
110 .Fn _fini | |
253
5cfe4322c500
- improved support for older OS versions for dynloads dlGetLibraryPath
Tassilo Philipp
parents:
250
diff
changeset
|
111 symbols exported (rare, but possible): Haiku (all versions), OpenBSD < 3.7, NetBSD < 5.1, FreeBSD < 4.8 |
250
7cb8a0aaf638
- note about c99 (+ anon struct/union) requirements in doc
Tassilo Philipp
parents:
248
diff
changeset
|
112 .Sh CONFORMING TO |
7cb8a0aaf638
- note about c99 (+ anon struct/union) requirements in doc
Tassilo Philipp
parents:
248
diff
changeset
|
113 The dynload library conforms to c99. |
7cb8a0aaf638
- note about c99 (+ anon struct/union) requirements in doc
Tassilo Philipp
parents:
248
diff
changeset
|
114 .Ed |
0 | 115 .Sh SEE ALSO |
116 .Xr dyncall 3 , | |
117 .Xr dyncallback 3 | |
93 | 118 and the dyncall manual (available in HTML and PDF format) for more information. |
0 | 119 .Sh AUTHORS |
120 .An "Daniel Adler" Aq dadler@uni-goettingen.de | |
121 .An "Tassilo Philipp" Aq tphilipp@potion-studios.com |