1 /* dlmain.c -- hello test program that uses simulated dynamic linking
3 Copyright (C) 1996-1999, 2004, 2006, 2007, 2010 Free Software
6 This file is part of GNU Libtool.
8 GNU Libtool is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 GNU Libtool is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Libtool; see the file COPYING. If not, a copy
20 can be downloaded from http://www.gnu.org/licenses/gpl.html,
21 or obtained by writing to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols
37 extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[];
40 main (int argc, char **argv)
42 const lt_dlsymlist *s;
47 printf ("Welcome to *modular* GNU Hell!\n");
49 /* Look up the symbols we require for this demonstration. */
50 s = lt_preloaded_symbols;
54 const char *name = s->name;
55 printf ("found symbol: %s\n", name);
56 if (!strcmp ("hello", name))
57 phello = (int(*)())s->address;
58 else if (!strcmp ("foo", name))
59 pfoo = (int(*)())s->address;
60 else if (!strcmp ("nothing", name))
62 /* In an ideal world we could do this... */
63 pnothing = (int*)s->address;
65 /* In an ideal world a shared lib would be able to export data */
66 pnothing = (int*)¬hing;
69 printf ("found file: %s\n", s->name);
73 /* Try assigning to the nothing variable. */
77 fprintf (stderr, "did not find the `nothing' variable\n");
79 /* Just call the functions and check return values. */
82 if ((*pfoo) () != FOO_RET)
86 fprintf (stderr, "did not find the `foo' function\n");
90 if ((*phello) () != HELLO_RET)
94 fprintf (stderr, "did not find the `hello' function\n");