0
|
1 /*
|
|
2
|
|
3 Package: dyncall
|
|
4 Library: test
|
|
5 File: test/nm/nm.c
|
|
6 Description:
|
|
7 License:
|
|
8
|
|
9 Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
|
|
10 Tassilo Philipp <tphilipp@potion-studios.com>
|
|
11
|
|
12 Permission to use, copy, modify, and distribute this software for any
|
|
13 purpose with or without fee is hereby granted, provided that the above
|
|
14 copyright notice and this permission notice appear in all copies.
|
|
15
|
|
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
|
24 */
|
|
25
|
|
26
|
|
27
|
|
28 #include "../../dynload/dynload.h"
|
|
29 #include "../../dynload/dynload_alloc.h"
|
|
30 #include "../common/platformInit.h"
|
|
31
|
|
32 void list_syms(const char* filePath)
|
|
33 {
|
|
34 DLSyms* pSyms;
|
|
35 int i,n;
|
|
36
|
|
37 pSyms = dlSymsInit(filePath);
|
|
38 if (!pSyms) {
|
|
39 fprintf(stderr, "dlSymsInit fail.");
|
|
40 return;
|
|
41 }
|
|
42 i = 0, n = dlSymsCount(pSyms);
|
|
43
|
|
44 for (; i < n; ++i) {
|
|
45 const char* name = dlSymsName(pSyms,i);
|
|
46 printf("%s\n", name);
|
|
47 }
|
|
48 dlSymsCleanup(pSyms);
|
|
49 }
|
|
50
|
|
51
|
|
52 int main(int argc, char* argv[])
|
|
53 {
|
|
54 int i, n;
|
|
55 DLLib* pLib;
|
|
56 const char* libPath;
|
|
57
|
|
58 if (argc == 1) {
|
|
59 fprintf(stderr, "usage : %s <dllpath>\n", argv[0]);
|
|
60 return 1;
|
|
61 }
|
|
62
|
|
63 libPath = argv[1];
|
|
64
|
|
65 /* load lib */
|
|
66
|
|
67 pLib = dlLoadLibrary(libPath);
|
|
68
|
|
69 if (!pLib) {
|
|
70 fprintf(stderr, "unable to open library %s\n", libPath);
|
|
71 return 2;
|
|
72 }
|
|
73
|
|
74 list_syms(libPath);
|
|
75
|
|
76 dlFreeLibrary(pLib);
|
|
77 return 0;
|
|
78 }
|
|
79
|