/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1997-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
*
* David Korn
* Glenn Fowler
* AT&T Research
*/
#include <ast.h>
#include <dlldefs.h>
#include <error.h>
#define T(x) ERROR_dictionary(x)
#if _BLD_dll && defined(__EXPORT__)
#define extern __EXPORT__
#endif
#if _hdr_dlfcn && _lib_dlopen
/*
* standard
*/
# include <dlfcn.h>
#else
#if _hdr_dl
/*
* HP-UX
*/
# include <dl.h>
# ifndef BIND_FIRST
# endif
# ifndef BIND_NOSTART
# endif
static int err;
{
void* dll;
if (!path)
return (void*)&all;
if (mode)
return dll;
}
{
return 0;
}
{
long addr;
{
return 0;
}
return (void*)addr;
}
extern char* dlerror(void)
{
char* msg;
if (!err)
return 0;
err = 0;
return msg;
}
#else
#if _sys_ldr && _lib_loadbind
/*
* rs6000
*/
# include <xcoff.h>
/* xcoff module header */
struct hdr
{
struct filehdr f;
struct aouthdr a;
struct scnhdr s[1];
};
static void* last_module;
static int err;
{
void* dll;
return dll;
}
{
return 0;
}
static int getquery(void)
{
if (!ld_info)
for (;;)
{
if (!ld_info)
return 1;
return 0;
return 1;
}
}
/* find the loaded module whose data area contains the
* address passed in. Remember that procedure pointers
* are implemented as pointers to descriptors in the
* data area of the module defining the procedure
*/
{
register int n = 1;
{
if (getquery())
return 0;
}
while (n)
{
+ (unsigned)(info->ldinfo_datasize)))
return info;
if (n=info->ldinfo_next)
}
return 0;
}
{
int i;
/* data is relocated by the difference between
* its virtual origin and where it was
* actually placed
*/
/*N.B. o_sndata etc. are one based */
/*hdr is address of header, not text, so add text s_scnptr */
/* search the exports symbols */
{
char *loc;
/* the symbol name representation is a nuisance since
* 8 character names appear in l_name but may
* not be null terminated. This code works around
* that by brute force
*/
{
symbuf[8] = 0;
}
else
continue;
return loc;
}
return 0;
}
{
void* addr;
if (!(info = getinfo(handle)) || !(addr = getloc(info->ldinfo_textorg,info->ldinfo_dataorg,(char*)name)))
{
return 0;
}
return addr;
}
extern char* dlerror(void)
{
char* msg;
if (!err)
return 0;
err = 0;
return msg;
}
#else
#if _hdr_dll && _lib_dllload
/*
* MVS
*/
# include <dll.h>
static int err;
{
void* dll;
return dll;
}
{
return 0;
}
{
void* addr;
return addr;
}
extern char* dlerror(void)
{
char* msg;
if (!err)
return 0;
err = 0;
return msg;
}
#else
#if _hdr_mach_o_dyld
/*
* mac[h]
*/
typedef struct Dll_s
{
unsigned long magic;
} Dll_t;
{
}
{
return om;
}
{
dlmessage = m;
}
{
};
{
int i;
static int init = 0;
if (!_dyld_present())
{
return 0;
}
if (!init)
{
init = 1;
}
if (!path)
{
return 0;
}
else
{
{
case NSObjectFileImageSuccess:
{
return 0;
}
break;
{
return 0;
}
break;
default:
return 0;
}
}
return (void*)dll;
}
{
{
return -1;
}
return 0;
}
static NSSymbol
{
unsigned long pun;
void* address;
{
return 0;
}
{
return 0;
}
else
{
if (!NSIsSymbolNameDefined(name))
return 0;
}
if (address)
return address;
}
{
{
return 0;
}
{
buf[0] = '_';
}
if (!address)
{
return 0;
}
return (void*)address;
}
extern char* dlerror(void)
{
char* msg;
dlmessage = 0;
return msg;
}
#else
/*
* punt
*/
static int err;
{
err = 1;
return 0;
}
{
err = 1;
return 0;
}
{
err = 1;
return 0;
}
extern char* dlerror(void)
{
if (!err)
return 0;
err = 0;
return "dynamic linking not supported";
}
#endif
#endif
#endif
#endif
#endif