0N/Aset prototyped
0N/Ahdr dl,dlfcn,dll,rld_interface,mach-o/dyld
0N/Asys ldr
0N/Alib dlopen -ldl
0N/Alib dllload,loadbind,shl_load -ldl
0N/Atst dll_DYNAMIC link{
0N/A #include <sys/types.h>
0N/A #include <link.h>
0N/A extern struct link_dynamic _DYNAMIC;
0N/A int
0N/A main()
0N/A {
0N/A return _DYNAMIC.ld_version;
0N/A }
0N/A}end
0N/Atst run{
0N/A lib=
0N/A for d in /shlib /usr/shlib /lib /usr/lib
873N/A do if test -d $d
0N/A then for s in "*.*" "*[!a]*"
0N/A do for b in libc
0N/A do for i in $d/$b.$s
0N/A do if test -f $i
0N/A then lib=$i
5085N/A fi
5294N/A done
0N/A case $lib in
0N/A ?*) break 3 ;;
2086N/A esac
0N/A done
0N/A done
0N/A fi
2568N/A done
0N/A case $lib in
0N/A *.[0-9]*.[0-9]*)
0N/A i=`echo $lib | sed 's,\([^0-9]*[0-9]*\).*,\1,'`
0N/A if test -f $i
2568N/A then lib=$i
0N/A fi
0N/A ;;
0N/A esac
2625N/A # some run time linkers barf with /lib/xxx if
2625N/A # /usr/lib/xxx is there
0N/A case $lib in
1340N/A /usr*) ;;
2734N/A *) if test -f /usr$lib
1340N/A then lib=/usr$lib
2086N/A fi
0N/A ;;
0N/A esac
1340N/A case $lib in
2086N/A "") lib=/lib/libc.so.1 ;;
2086N/A esac
2086N/A case $lib in
0N/A /usr/lib/*)
0N/A case `package` in
0N/A sgi.mips3)
0N/A abi=/lib32
0N/A ;;
0N/A sgi.mips4)
0N/A abi=/lib64
0N/A ;;
0N/A *) abi=
0N/A ;;
0N/A esac
0N/A case $abi in
0N/A ?*) if test -d $abi
0N/A then lib=`echo $lib | sed 's,/usr/lib/,,'`
2568N/A lib=$abi/$lib
2568N/A fi
2568N/A ;;
2568N/A esac
2568N/A ;;
2568N/A esac
2568N/A echo "#define _DLL_NEXT_PATH \"$lib\""
2568N/A}end
2568N/Atst - output{
2625N/A #if defined(__MVS__) && !defined(__SUSV3)
2568N/A #define __SUSV3 1
0N/A #endif
0N/A #if _hdr_dlfcn && _lib_dlopen
0N/A #include <dlfcn.h>
3285N/A #endif
3285N/A #if _hdr_rld_interface
3285N/A #include <rld_interface.h>
3285N/A #endif
0N/A int
0N/A main()
0N/A {
0N/A int i;
0N/A #if _hdr_rld_interface
0N/A void* dll;
0N/A static char* local[] = { "__elf_header", "_call_add_gp_range", "_etext" };
0N/A #endif
0N/A printf("\n");
0N/A printf("#if defined(__MVS__) && !defined(__SUSV3)\n");
0N/A printf("#define __SUSV3 1\n");
1340N/A printf("#endif\n");
1340N/A #if _hdr_dlfcn && _lib_dlopen
921N/A printf("#include <dlfcn.h>\n");
2859N/A #endif
2859N/A #ifndef RTLD_LAZY
2859N/A i = 0;
0N/A printf("\n");
0N/A printf("#define RTLD_LAZY 1\n");
0N/A #else
0N/A i = 1;
0N/A #endif
0N/A #ifndef RTLD_NOW
0N/A if (i)
0N/A {
0N/A i = 0;
0N/A printf("\n");
0N/A }
0N/A printf("#define RTLD_NOW 2\n");
0N/A #endif
0N/A #ifndef RTLD_GLOBAL
0N/A if (i)
0N/A {
0N/A i = 0;
0N/A printf("\n");
0N/A }
0N/A printf("#define RTLD_GLOBAL 0\n");
0N/A #endif
0N/A #ifndef RTLD_LOCAL
0N/A if (i)
0N/A {
0N/A i = 0;
536N/A printf("\n");
536N/A }
2086N/A printf("#define RTLD_LOCAL 0\n");
536N/A #endif
0N/A #ifndef RTLD_PARENT
0N/A if (i)
0N/A {
0N/A i = 0;
0N/A printf("\n");
0N/A }
0N/A printf("#define RTLD_PARENT 0\n");
2625N/A #endif
2625N/A #if defined(_hdr_mach_o_dyld) && !defined(RTLD_NEXT)
2625N/A if (i)
2625N/A {
2625N/A i = 0;
2625N/A printf("\n");
2625N/A }
2625N/A printf("#define RTLD_NEXT ((void*)16)\n");
2625N/A #endif
2625N/A #if _hdr_rld_interface
2625N/A if (!(dll = dlopen(0, RTLD_LAZY)))
2625N/A i = -1;
2625N/A else
2625N/A {
4581N/A for (i = 0; i < sizeof(local) / sizeof(local[0]); i++)
4581N/A if (dlsym(dll, local[i]))
2625N/A break;
2625N/A if (i >= sizeof(local) / sizeof(local[0]))
2625N/A i = -1;
2625N/A }
2625N/A if (i >= 0)
2625N/A {
2625N/A printf("\n");
4581N/A printf("#define _DLL_RLD_SYM %s\n", local[i]);
2625N/A printf("#define _DLL_RLD_SYM_STR \"%s\"\n", local[i]);
2625N/A printf("#define _DLL_RLD_SYM_TYPE void*\n");
2625N/A }
2625N/A #endif
2625N/A printf("\n");
2625N/A printf("#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */\n");
2625N/A printf("#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */\n");
2625N/A printf("\n");
2625N/A printf("typedef struct Dllinfo_s\n");
2625N/A printf("{\n");
2625N/A printf(" char** sibling; /* sibling dirs on $PATH */\n");
2625N/A printf(" char* prefix; /* library name prefix */\n");
0N/A printf(" char* suffix; /* library name suffix */\n");
0N/A printf(" char* env; /* library path env var */\n");
2734N/A printf(" int flags; /* DLL_INFO_* flags */\n");
2734N/A printf("#ifdef _DLLINFO_PRIVATE_\n");
2734N/A printf(" _DLLINFO_PRIVATE_\n");
0N/A printf("#endif\n");
0N/A printf("} Dllinfo_t;\n");
0N/A printf("\n");
0N/A printf("typedef struct Dllent_s\n");
0N/A printf("{\n");
0N/A printf(" char* path;\n");
0N/A printf(" char* name;\n");
0N/A printf("#ifdef _DLLENT_PRIVATE_\n");
536N/A printf(" _DLLENT_PRIVATE_\n");
536N/A printf("#endif\n");
536N/A printf("} Dllent_t;\n");
0N/A printf("\n");
0N/A printf("typedef struct Dllscan_s\n");
0N/A printf("{\n");
2086N/A printf(" void* pad;\n");
0N/A printf("#ifdef _DLLSCAN_PRIVATE_\n");
0N/A printf(" _DLLSCAN_PRIVATE_\n");
0N/A printf("#endif\n");
536N/A printf("} Dllscan_t;\n");
0N/A #if !_hdr_dlfcn || !_lib_dlopen
0N/A printf("\n");
0N/A printf("extern void* dlopen(const char*, int);\n");
0N/A printf("extern void* dlsym(void*, const char*);\n");
0N/A printf("extern int dlclose(void*);\n");
0N/A printf("extern char* dlerror(void);\n");
0N/A #endif
1340N/A printf("\n");
2859N/A printf("#if _BLD_dll && defined(__EXPORT__)\n");
0N/A printf("#define extern __EXPORT__\n");
0N/A printf("#endif\n");
0N/A printf("\n");
0N/A printf("extern Dllinfo_t* dllinfo(void);\n");
0N/A printf("extern void* dllplug(const char*, const char*, const char*, int, char*, size_t);\n");
0N/A printf("extern void* dllfind(const char*, const char*, int, char*, size_t);\n");
2568N/A printf("extern void* dllopen(const char*, int);\n");
2625N/A printf("extern void* dllnext(int);\n");
0N/A printf("extern void* dlllook(void*, const char*);\n");
2625N/A #if _hdr_rld_interface
0N/A if (i >= 0)
0N/A {
0N/A printf("\n");
0N/A printf("extern void* _dll_next(int, _DLL_RLD_SYM_TYPE*);\n");
2625N/A printf("#define dllnext(f) _dll_next(f, &_DLL_RLD_SYM)\n");
2625N/A }
0N/A #endif
0N/A printf("\n");
0N/A printf("extern Dllscan_t* dllsopen(const char*, const char*, const char*);\n");
0N/A printf("extern Dllent_t* dllsread(Dllscan_t*);\n");
0N/A printf("extern int dllsclose(Dllscan_t*);\n");
0N/A printf("\n");
0N/A printf("#undef extern\n");
0N/A #if _hdr_rld_interface
536N/A if (i >= 0)
536N/A {
536N/A printf("\n");
0N/A printf("extern _DLL_RLD_SYM_TYPE _DLL_RLD_SYM;\n");
0N/A }
0N/A #endif
0N/A printf("\n");
0N/A return 0;
0N/A }
0N/A}end
0N/A