2 * Author: Jeff Okamoto (okamoto@corp.hp.com)
3 * Version: 2.1, 1995/1/25
6 /* o Added BIND_VERBOSE to dl_nonlazy condition to add names of missing
7 * symbols to stderr message on fatal error.
9 * o Added BIND_NONFATAL comment to default condition.
11 * Chuck Phillips (cdp@fc.hp.com)
12 * Version: 2.2, 1997/5/4 */
15 #define magic hpux_magic
16 #define MAGIC HPUX_MAGIC
30 #include "dlutils.c" /* for SaveError() etc */
32 static AV *dl_resolve_using = Nullav;
38 (void)dl_generic_private_init(aTHX);
39 dl_resolve_using = get_av("DynaLoader::dl_resolve_using", 0x4);
42 MODULE = DynaLoader PACKAGE = DynaLoader
45 (void)dl_private_init(aTHX);
49 dl_load_file(filename, flags=0)
54 int i, max, bind_type;
56 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
58 Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
60 bind_type = BIND_IMMEDIATE|BIND_VERBOSE;
62 bind_type = BIND_DEFERRED;
63 /* For certain libraries, like DCE, deferred binding often causes run
64 * time problems. Adding BIND_NONFATAL to BIND_IMMEDIATE still allows
65 * unresolved references in situations like this. */
66 /* bind_type = BIND_IMMEDIATE|BIND_NONFATAL; */
68 /* BIND_NOSTART removed from bind_type because it causes the shared library's */
69 /* initialisers not to be run. This causes problems with all of the static objects */
73 bind_type |= BIND_VERBOSE;
74 #endif /* DEBUGGING */
76 max = AvFILL(dl_resolve_using);
77 for (i = 0; i <= max; i++) {
78 char *sym = SvPVX(*av_fetch(dl_resolve_using, i, 0));
79 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s) (dependent)\n", sym));
80 obj = shl_load(sym, bind_type, 0L);
86 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s): ", filename));
87 obj = shl_load(filename, bind_type, 0L);
89 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", obj));
91 ST(0) = sv_newmortal() ;
93 SaveError(aTHX_ "%s",Strerror(errno));
95 sv_setiv( ST(0), PTR2IV(obj) );
99 dl_find_symbol(libhandle, symbolname)
103 shl_t obj = (shl_t) libhandle;
104 void *symaddr = NULL;
107 symbolname = form("_%s", symbolname);
109 DLDEBUG(2, PerlIO_printf(Perl_debug_log,
110 "dl_find_symbol(handle=%lx, symbol=%s)\n",
111 (unsigned long) libhandle, symbolname));
113 ST(0) = sv_newmortal() ;
116 status = shl_findsym(&obj, symbolname, TYPE_PROCEDURE, &symaddr);
117 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " symbolref(PROCEDURE) = %x\n", symaddr));
119 if (status == -1 && errno == 0) { /* try TYPE_DATA instead */
120 status = shl_findsym(&obj, symbolname, TYPE_DATA, &symaddr);
121 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " symbolref(DATA) = %x\n", symaddr));
125 SaveError(aTHX_ "%s",(errno) ? Strerror(errno) : "Symbol not found") ;
127 sv_setiv( ST(0), PTR2IV(symaddr) );
137 # These functions should not need changing on any platform:
140 dl_install_xsub(perl_name, symref, filename="$Package")
145 DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%x)\n",
147 ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name,
148 (void(*)(pTHX_ CV *))symref,