2 hdr dl,dlfcn,dll,rld_interface,mach-o/dyld
5 lib dllload,loadbind,shl_load -ldl
9 extern struct link_dynamic _DYNAMIC;
13 return _DYNAMIC.ld_version;
18 for d in /shlib /usr/shlib /lib /usr/lib
20 then for s in "*.*" "*[!a]*"
36 i=`echo $lib | sed 's,\([^0-9]*[0-9]*\).*,\1,'`
42 # some run time linkers barf with /lib/xxx if
43 # /usr/lib/xxx is there
46 *) if test -f /usr$lib
52 "") lib=/lib/libc.so.1 ;;
68 then lib=`echo $lib | sed 's,/usr/lib/,,'`
75 echo "#define _DLL_NEXT_PATH \"$lib\""
78 #if defined(__MVS__) && !defined(__SUSV3)
81 #if _hdr_dlfcn && _lib_dlopen
84 #if _hdr_rld_interface
85 #include <rld_interface.h>
91 #if _hdr_rld_interface
93 static char* local[] = { "__elf_header", "_call_add_gp_range", "_etext" };
96 printf("#if defined(__MVS__) && !defined(__SUSV3)\n");
97 printf("#define __SUSV3 1\n");
99 #if _hdr_dlfcn && _lib_dlopen
100 printf("#include <dlfcn.h>\n");
105 printf("#define RTLD_LAZY 1\n");
115 printf("#define RTLD_NOW 2\n");
123 printf("#define RTLD_GLOBAL 0\n");
131 printf("#define RTLD_LOCAL 0\n");
139 printf("#define RTLD_PARENT 0\n");
141 #if defined(_hdr_mach_o_dyld) && !defined(RTLD_NEXT)
147 printf("#define RTLD_NEXT ((void*)16)\n");
149 #if _hdr_rld_interface
150 if (!(dll = dlopen(0, RTLD_LAZY)))
154 for (i = 0; i < sizeof(local) / sizeof(local[0]); i++)
155 if (dlsym(dll, local[i]))
157 if (i >= sizeof(local) / sizeof(local[0]))
163 printf("#define _DLL_RLD_SYM %s\n", local[i]);
164 printf("#define _DLL_RLD_SYM_STR \"%s\"\n", local[i]);
165 printf("#define _DLL_RLD_SYM_TYPE void*\n");
169 printf("#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */\n");
170 printf("#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */\n");
172 printf("typedef struct Dllinfo_s\n");
174 printf(" char** sibling; /* sibling dirs on $PATH */\n");
175 printf(" char* prefix; /* library name prefix */\n");
176 printf(" char* suffix; /* library name suffix */\n");
177 printf(" char* env; /* library path env var */\n");
178 printf(" int flags; /* DLL_INFO_* flags */\n");
179 printf("#ifdef _DLLINFO_PRIVATE_\n");
180 printf(" _DLLINFO_PRIVATE_\n");
182 printf("} Dllinfo_t;\n");
184 printf("typedef struct Dllent_s\n");
186 printf(" char* path;\n");
187 printf(" char* name;\n");
188 printf("#ifdef _DLLENT_PRIVATE_\n");
189 printf(" _DLLENT_PRIVATE_\n");
191 printf("} Dllent_t;\n");
193 printf("typedef struct Dllscan_s\n");
195 printf(" void* pad;\n");
196 printf("#ifdef _DLLSCAN_PRIVATE_\n");
197 printf(" _DLLSCAN_PRIVATE_\n");
199 printf("} Dllscan_t;\n");
200 #if !_hdr_dlfcn || !_lib_dlopen
202 printf("extern void* dlopen(const char*, int);\n");
203 printf("extern void* dlsym(void*, const char*);\n");
204 printf("extern int dlclose(void*);\n");
205 printf("extern char* dlerror(void);\n");
208 printf("#if _BLD_dll && defined(__EXPORT__)\n");
209 printf("#define extern __EXPORT__\n");
212 printf("extern Dllinfo_t* dllinfo(void);\n");
213 printf("extern void* dllplug(const char*, const char*, const char*, int, char*, size_t);\n");
214 printf("extern void* dllfind(const char*, const char*, int, char*, size_t);\n");
215 printf("extern void* dllopen(const char*, int);\n");
216 printf("extern void* dllnext(int);\n");
217 printf("extern void* dlllook(void*, const char*);\n");
218 #if _hdr_rld_interface
222 printf("extern void* _dll_next(int, _DLL_RLD_SYM_TYPE*);\n");
223 printf("#define dllnext(f) _dll_next(f, &_DLL_RLD_SYM)\n");
227 printf("extern Dllscan_t* dllsopen(const char*, const char*, const char*);\n");
228 printf("extern Dllent_t* dllsread(Dllscan_t*);\n");
229 printf("extern int dllsclose(Dllscan_t*);\n");
231 printf("#undef extern\n");
232 #if _hdr_rld_interface
236 printf("extern _DLL_RLD_SYM_TYPE _DLL_RLD_SYM;\n");